close
Skip to content

DataViews: Add scrollY layout option for table views#76091

Closed
dilirity wants to merge 6 commits intoWordPress:trunkfrom
dilirity:add/dataviews-table-scroll-y-layout-option
Closed

DataViews: Add scrollY layout option for table views#76091
dilirity wants to merge 6 commits intoWordPress:trunkfrom
dilirity:add/dataviews-table-scroll-y-layout-option

Conversation

@dilirity
Copy link
Copy Markdown
Contributor

@dilirity dilirity commented Mar 3, 2026

What?

Adds a new scrollY layout option to the DataViews table and pickerTable view types.

CleanShot.2026-03-10.at.11.18.23.mp4
CleanShot.2026-03-10.at.11.17.03.mp4

Why?

Currently, the entire DataViews wrapper scrolls as one unit. When using free composition to build custom layouts - for example, with route tabs and view actions in a shared toolbar above the table - the table body needs to scroll independently within a constrained container while keeping the toolbar and table headers fixed.

Free composition gives control over the layout of the surrounding UI, but the table itself still needs to know where vertical scrolling should occur. Without this option, the only way to achieve this behavior is to override internal DataViews styles, which is fragile and breaks the sticky actions column border logic.

Additionally, the horizontal scroll needs to be handled by the correct container so the sticky actions column shows its border only when overlapping content.

How?

  • Adds scrollY?: 'wrapper' | 'table' to the ViewTable and ViewPickerTable layout types. Defaults to 'wrapper' (current behavior).
  • When scrollY is 'table', the wrapper disables vertical overflow (overflow-y: hidden) and the table is wrapped in an inner scroll container that handles both vertical and horizontal scrolling.
  • A new scrollContainerRef is threaded through DataViewsContext so the table component can expose the inner scroll element to the parent for infinite scroll support and horizontal scroll-end detection.
  • The infinite scroll listener in both DataViews and DataViewsPicker attaches to the correct scroll container based on the mode.
  • useIsHorizontalScrollEnd receives the appropriate ref so the actions column border logic works with either scroll mode.

Testing Instructions

  1. Use a DataViews table with view.layout.scrollY set to 'table'.
  2. Verify filters and view actions stay fixed while the table body scrolls vertically.
  3. Scroll horizontally and confirm the actions column shows a left border when overlapping content, and no border when scrolled fully right.
  4. Test with scrollY unset or set to 'wrapper' to confirm default behavior is unchanged.
  5. If using infinite scroll, verify it triggers correctly in both modes.

Testing Instructions for Keyboard

  1. Storybook for DataViews -> Free Composition Scroll Y demonstrates the scrollY: 'table' option in a layout with route tabs and view actions in a shared toolbar. The table body scrolls while the toolbar and
    thead stay fixed.
  2. Storybook for DataViews -> Layout Table also has a scrollY control to toggle between wrapper and table modes.
CleanShot 2026-03-10 at 11 19 35@2x

Introduce a `scrollY` layout property for table and pickerTable views
that controls where vertical scrolling occurs. When set to `'table'`,
the table body scrolls independently while filters and actions remain
fixed at the top. Horizontal scroll detection is also delegated to
the inner scroll container so the sticky actions column border
appears correctly.
@github-actions github-actions bot added the [Package] DataViews /packages/dataviews label Mar 3, 2026
@dilirity dilirity marked this pull request as ready for review March 4, 2026 09:09
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

Warning: Type of PR label mismatch

To merge this PR, it requires exactly 1 label indicating the type of PR. Other labels are optional and not being checked here.

  • Required label: Any label starting with [Type].
  • Labels found: Needs Design Feedback, [Package] DataViews.

Read more about Type labels in Gutenberg. Don't worry if you don't have the required permissions to add labels; the PR reviewer should be able to help with the task.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 4, 2026

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: dilirity <dilirity@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: gigitux <gigitux@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@dilirity
Copy link
Copy Markdown
Contributor Author

dilirity commented Mar 4, 2026

Closing as not needed.

@dilirity dilirity closed this Mar 4, 2026
@dilirity dilirity reopened this Mar 6, 2026
@dilirity dilirity marked this pull request as draft March 6, 2026 11:21
@oandregal
Copy link
Copy Markdown
Member

Would you be able to use free form instead to have this kind of interaction? Examples: free composition, minimal UI.

@oandregal oandregal added the Needs Design Feedback Needs general design feedback. label Mar 10, 2026
@dilirity
Copy link
Copy Markdown
Contributor Author

dilirity commented Mar 10, 2026

Would you be able to use free form instead to have this kind of interaction? Examples: free composition, minimal UI.

free form doesn't solve this on its own - I've included a storybook (Free Composition Scroll Y) showing free composition that still needs scrollY: 'table' to work correctly.

@dilirity dilirity marked this pull request as ready for review March 10, 2026 10:27
@gigitux
Copy link
Copy Markdown
Contributor

gigitux commented Mar 12, 2026

I opened an alternative PR #76453

@gigitux
Copy link
Copy Markdown
Contributor

gigitux commented Mar 17, 2026

I'm going to close this PR given that #76453 has been merged! Kudos to @dilirity for this exploration! 🙇

@gigitux gigitux closed this Mar 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs Design Feedback Needs general design feedback. [Package] DataViews /packages/dataviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants