glideapps / glideapps/glide-data-grid
Provide a hook for post-resize/reflow, when contents are ready to be scrolled
- Dominant language
- TypeScript
- Stars
- 5.3k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
It would be ideal to have a hook provided by glide data grid when grid resize/reflow has completed, and `scrollTo()` can be called safely. Right now, placing a ResizeObserver on the glide data grid container correctly identifies the moment the container size changes, but Glide hasn't completed its internal reflow yet so `scrollTo()` does nothing.
I came across this issue after placing the glide data grid into a [dockview](https://dockview.dev/) panel and tried to keep scroll position after the user flips to a different panel and then back to the data grid. Dockview applies `display:none` to non-focused panels, causing the Glide data grid's size to be 0x0.
Glide correctly resizes back to the container size when focus switches back to the panel containing the data grid, however there's no way for us to identify when its safe to call scrollTo(). Attempting to call it before Glide has completed its internal size reflow has no effect. Unfortunately even waiting for `gridRef.current.getBounds()` to return a non-zero size also doesn't work - the rows aren't populated by then. It takes another 2-3 animation frames before `scrollTo` works, and that results in a brief flicker.
See also: https://github.com/mathuo/dockview/issues/1063
Contributor guide
Assessment
This issue has not been assessed yet.