-
Notifications
You must be signed in to change notification settings - Fork 650
Preserve element size during drag with contain-intrinsic-size #7446
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
base: main
Are you sure you want to change the base?
Conversation
|
Co-authored-by: mattcosta7 <[email protected]>
|
👋 Hi, this pull request contains changes to the source code that github/github-ui depends on. If you are GitHub staff, test these changes with github/github-ui using the integration workflow. Or, apply the |
| } | ||
| if (contentWrapper) { | ||
| const rect = contentWrapper.getBoundingClientRect() | ||
| contentWrapper.style.setProperty('contain-intrinsic-size', `${rect.width}px ${rect.height}px`) |
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.
@copilot should we use auto width here instead of a fixed width, since we're changing width or is this ok
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.
Good catch! Updated to use auto ${width}px auto ${height}px format. This allows the browser to track the actual rendered size rather than using a fixed size captured at drag start, which is important since the pane width changes dynamically during drag via --pane-width CSS variable updates.
Fixed in commit 1d93cdb.
Co-authored-by: mattcosta7 <[email protected]>
When dragging resizable panes,
content-visibility: autocauses off-screen content to collapse, triggering layout shifts and scroll jumping. This maintains the performance optimization while stabilizing layout.Implementation
paneUtils.ts- Modified drag style management:setDraggingStyles(): Captures element dimensions viagetBoundingClientRect()and setscontain-intrinsic-sizeinline style withautokeyword before applyingdata-draggingattributeremoveDraggingStyles(): Removescontain-intrinsic-sizeafter drag endsCSS - No changes needed,
content-visibility: autoremains active during drag for performanceMechanism
The
contain-intrinsic-sizeproperty withautokeyword provides a size hint to the browser whencontent-visibility: autoskips rendering. Theautoallows the browser to track the actual rendered size as the pane width changes dynamically during drag operations via--pane-widthCSS variable updates.Changelog
Changed
setDraggingStyles()now captures and preserves element dimensions during drag operations usingautokeyword for dynamic sizingremoveDraggingStyles()cleans up dimension hints after dragRollout strategy
Testing & Reviewing
Tests verify
contain-intrinsic-sizeis applied withauto <width>px auto <height>pxformat during both pointer and keyboard drag operations, and removed on drag end. Verify dragging near scrollable container edges shows no layout jumps.Merge checklist
Original prompt
This pull request was created from Copilot chat.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.