Preserve element size during drag with contain-intrinsic-size#7446
Preserve element size during drag with contain-intrinsic-size#7446
Conversation
|
Co-authored-by: mattcosta7 <8616962+mattcosta7@users.noreply.github.com>
|
👋 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.
@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.
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 <8616962+mattcosta7@users.noreply.github.com>
|
Hi! This pull request has been marked as stale because it has been open with no activity for 60 days. You can comment on the pull request or remove the stale label to keep it open. If you do nothing, this pull request will be closed in 7 days. |
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.