Repository navigation
fix: honor box changes when measuring parent size - #107
Conversation
|
@feritcemkahraman is attempting to deploy a commit to the Brian Vaughn's projects Team on Vercel. A member of the Team first needs to authorize it. |
bvaughn
left a comment
There was a problem hiding this comment.
This seems like a problem worth fixing, so thanks for pointing it out 👍🏼
I think the fix might be too narrowly focused, because it doesn't handle the fallback case:
react-virtualized-auto-sizer/lib/hooks/useSize.ts
Lines 142 to 151 in 328ddd0
Admittedly this case is probably only very rarely used but even so it seems like it would be nice to fix both 😄
We could do that by adding box to the stableValuesRef, updating the callback ref to read box from that ref instead, and then re-evaluating the callback if the prop changes:
useLayoutEffect(() => {
stableValuesRef.current.box = box;
onResizeStableRef.current();
}, [box]);If you're down for making that change– awesome. If not, I'm happy to chip in.
🔔 @bvaughn
There was a problem hiding this comment.
While we're in here we could fix this too:
| cons getComputedStyle = parentNode.ownerDocument.defaultView.getComputedStyle; | |
| const style = getComputedStyle(parentNode) || {}; |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Published in 2.0.4: https://github.com/bvaughn/react-virtualized-auto-sizer/releases/tag/2.0.4 Thanks again! |
Changing AutoSizer's box prop after mounting leaves measurements using the original box model. Switching from border-box to content-box should immediately remove padding and borders from the reported size, even without another resize event.
Keep box in the existing stable values ref and remeasure in a layout effect when it changes. Both observer and fallback subscriptions remain stable. Read computed styles from the measured element's own window.
Validation: the immediate fallback regressions and stable-observer regression failed on the previous revision; all 7 unit tests, full TypeScript, ESLint, formatting, and the library CJS/ESM/declaration build pass. Docs/examples were generated earlier with a temporary, restored Windows tooling adapter; the review changes leave the public API and generated content unchanged. Browser integration and cross-document browser tests were not run.