DataViews: Fix layout scrolling in constrained-height containers#76453
DataViews: Fix layout scrolling in constrained-height containers#76453
Conversation
|
Size Change: +201 B (0%) Total Size: 8.75 MB
ℹ️ View Unchanged
|
| </Stack> | ||
| </CardBody> | ||
| </Card> | ||
| <DataViews.Layout className="free-composition-dataviews-layout" /> |
There was a problem hiding this comment.
I think that this was a mistake. Before Layout was a child of the free-composition-header div.
|
Flaky tests detected in 0c4bbb7. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23147036487
|
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Pull request overview
This PR adjusts DataViews so that, when rendered inside a constrained-height container, scrolling is handled by the active layout region rather than by an outer wrapper—making it easier to compose surrounding UI while keeping the data area as the scrollable region.
Changes:
- Wrap the active layout component in a new flex child container that can shrink and become the scroll container (
overflow: auto,min-height: 0). - Update Storybook “Free Composition” to allow selecting a container height and to better demonstrate constrained-height behavior.
- Add a changelog entry documenting the scrolling behavior change.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/dataviews/src/style.scss | Imports the new layout-container SCSS so the new scroll container styles are applied. |
| packages/dataviews/src/components/dataviews-layout/index.tsx | Wraps the active layout in a new .dataviews-layout__container element. |
| packages/dataviews/src/components/dataviews-layout/style.scss | Adds flex/overflow styles to make the layout region the scroll container. |
| packages/dataviews/src/dataviews/stories/free-composition.tsx | Adjusts the Free Composition story structure and makes container height configurable. |
| packages/dataviews/src/dataviews/stories/index.story.tsx | Adds Storybook controls for containerHeight on the Free Composition story. |
| packages/dataviews/src/dataviews/stories/style.css | Removes story-level outer scrolling on .free-composition. |
| packages/dataviews/CHANGELOG.md | Documents the behavior change in the package changelog. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| <DataViews.Layout className="free-composition-dataviews-layout" /> | ||
| </Stack> | ||
| </div> | ||
| <DataViews.Layout className="free-composition-dataviews-layout" /> |
There was a problem hiding this comment.
In this story, moving <DataViews.Layout /> outside of the header wrapper changes which element is actually scrolling (now the internal .dataviews-layout__container). The story CSS still offsets the table header with .free-composition-dataviews-layout thead { inset-block-start: 67px; }, which was likely compensating for a sticky header inside the same scroll container. With the header now outside the scroll area, this offset will leave an unnecessary gap when the thead becomes sticky. Consider updating/removing that offset so the sticky thead aligns to the top of the layout scroll container.
| <DataViews.Layout className="free-composition-dataviews-layout" /> | |
| <DataViews.Layout /> |
packages/dataviews/CHANGELOG.md
Outdated
| - DataViews: Fix scrolling so the scrollbar appears on the active layout when DataViews is rendered in a constrained-height container. This may slightly change the UI depending on the container height. [#76453](https://github.com/WordPress/gutenberg/pull/76453) | ||
|
|
There was a problem hiding this comment.
This changelog entry is a bug fix (and references an issue), but it’s currently placed under “### Enhancements”, and it also introduces an extra blank line within the bullet list. Consider moving it under “### Bug Fixes” and keeping the bullet formatting consistent with the surrounding entries (no empty line between bullets).
|
This change makes sense to me from a design perspective and feels like a genuine enhancement, but let's see if @WordPress/gutenberg-design has any thoughts. |
|
All that is fair, and I won't block this PR from landing, I think it's important we iterate this componentry pretty freely so we can work out all the kinks. But as a permanent state of things, I don't think it's ideal, it's something we should come back to. (Which I can say for nearly everything.) |
|
Thanks for the feedback, folks! @oandregal @ntsekouras can I get your feedback on this PR? Thanks! 🙇 |
| containerHeight: '80vh', | ||
| }, | ||
| argTypes: { | ||
| containerHeight: { |
There was a problem hiding this comment.
Can you add the same control to the other layout table, grid, list, activity, and custom stories? There's precedent about this control in the empty story as well.
|
There's still an |
|
This change means scrolling is attached to the DataViews Layout if the DataViews container sets a height, and otherwise scroll would be attached to the window: Screen.Recording.2026-03-16.at.14.14.55.movI concur with Joen about this change leaving a lot of vertical space unused (specially when filters are displayed). Before is left, after is right: Screen.Recording.2026-03-16.at.13.40.34.movHappy to land this and iterate. |
oandregal
left a comment
There was a problem hiding this comment.
Left a couple of comments to look at: stories, redundant overflow?
| overflow: auto; | ||
| } | ||
| ` }</style> | ||
| <Text |
There was a problem hiding this comment.
This code was in place to ensure that infinite scroll was triggered on this story at any window size. Removing it has broken infinite scrolling in the story.


What?
Based on the exploration done with #76091 (cc kudos to @dilirity), this PR fixes DataViews scrolling so the scrollbar appears on the active layout, instead of an outer wrapper, when DataViews is rendered in a constrained-height container.
This can cause a small UI change depending on the container height, because scrolling now happens in the layout region itself.
Why?
When the parent container constrained the available height, the scrollbar could appear on an outer container instead of on the actual layout.
That made the scrolling behavior inconsistent and made it harder to compose surrounding UI while keeping the data area as the proper scrollable region.
Testing Instructions
DataViewsinside a container with constrained height.You can check it checking the
Free Compositionstories.This PR fixes the issue reported in #66226
CleanShot.2026-03-12.at.16.20.13.1.mp4
CleanShot.2026-03-12.at.16.22.18.mp4