Skip to content

DataViews: Add scrollY layout option for table views#76091

Closed
dilirity wants to merge 4 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 4 commits intoWordPress:trunkfrom
dilirity:add/dataviews-table-scroll-y-layout-option

Conversation

@dilirity
Copy link
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-04.at.11.12.16.mp4

Why?

Currently, the entire DataViews wrapper scrolls as one unit. In some use cases (e.g. dense admin tables), it's desirable to keep the view actions and filters pinned at the top while only the table body scrolls vertically. 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 -> Layout Table has been updated to include a new option - scrollY. Switch to wrapper to see the original scroll behavior, or table to see the new scroll behavior:
CleanShot 2026-03-04 at 11 06 53@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

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: [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

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>

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

@dilirity
Copy link
Contributor Author

dilirity commented Mar 4, 2026

Closing as not needed.

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

Labels

[Package] DataViews /packages/dataviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant