-
Notifications
You must be signed in to change notification settings - Fork 117
Address ResizeObserver not working in secondary windows by polling for size changes in the DataGridWaffle #9000
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Address ResizeObserver not working in secondary windows by polling for size changes in the DataGridWaffle #9000
Conversation
…r size changes in the DataGridWaffle
E2E Tests 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great - thanks for walking me through the changes! I had a small suggestion and a question but they aren't blockers to merging by any means.
// ResizeObserver does not work well on elements inside secondary Electron windows. This causes issues | ||
// with the data grid's automatic layout feature, which relies on knowing when the size of the data grid | ||
// waffle changes. See https://github.com/posit-dev/positron/issues/8695. This workaround ensures that the | ||
// initial data grid waffle's size is updated when the component is mounted. | ||
DOM.getWindow(dataGridWaffleRef.current).requestAnimationFrame(async () => | ||
await setSize(dataGridWaffleRef.current.offsetWidth, dataGridWaffleRef.current.offsetHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion to change the comment to be a bit more explicit about why we are using requestAnimationFrame
. This change is more for me if I ever have to look at this again 😂
// ResizeObserver does not work well on elements inside secondary Electron windows. This causes issues | |
// with the data grid's automatic layout feature, which relies on knowing when the size of the data grid | |
// waffle changes. See https://github.com/posit-dev/positron/issues/8695. This workaround ensures that the | |
// initial data grid waffle's size is updated when the component is mounted. | |
DOM.getWindow(dataGridWaffleRef.current).requestAnimationFrame(async () => | |
await setSize(dataGridWaffleRef.current.offsetWidth, dataGridWaffleRef.current.offsetHeight) | |
// ResizeObserver does not work well on elements inside secondary Electron windows. This causes issues | |
// with the data grid's automatic layout feature, which relies on knowing when the size of the data grid | |
// waffle changes. See https://github.com/posit-dev/positron/issues/8695. Using `requestAnimationFrame` | |
// ensures that the initial size of the data grid waffle is set when the component is mounted. | |
DOM.getWindow(dataGridWaffleRef.current).requestAnimationFrame(async () => | |
await setSize(dataGridWaffleRef.current.offsetWidth, dataGridWaffleRef.current.offsetHeight) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Description
This PR addresses #8695. The root cause of this issue is that ResizeObserver does not work well on elements inside secondary Electron windows. This causes issues with the Data Grid's automatic layout feature, which relies on knowing when the size of the Data Grid waffle changes. In a secondary Electron window, the workaround is to poll for changes in the Data Grid waffle’s size.
Release Notes
New Features
Bug Fixes
QA Notes