Skip to content

Conversation

softwarenerd
Copy link
Contributor

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

  • N/A

Bug Fixes

QA Notes

Copy link

github-actions bot commented Aug 12, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

dhruvisompura
dhruvisompura previously approved these changes Aug 12, 2025
Copy link
Contributor

@dhruvisompura dhruvisompura left a 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.

Comment on lines 95 to 100
// 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)
Copy link
Contributor

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 😂

Suggested change
// 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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@softwarenerd softwarenerd merged commit fb64136 into main Sep 2, 2025
9 checks passed
@softwarenerd softwarenerd deleted the fix/data-explorer-automatic-layout-fails-after-move-into-new-window branch September 2, 2025 17:42
@github-actions github-actions bot locked and limited conversation to collaborators Sep 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants