Skip to content

DataViews: Show that a table has more columns to scroll - #85949

Closed
yaman-694 wants to merge 9 commits into
WordPress:trunkfrom
yaman-694:add/dataviews-table-scroll-fade
Closed

yaman-694 wants to merge 9 commits into
WordPress:trunkfrom
yaman-694:add/dataviews-table-scroll-fade

Conversation

@yaman-694

@yaman-694 yaman-694 commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #85898

Fades the trailing edge of a DataViews table while there are more columns to scroll to, and hides the fade at the end of the scroll range.

Why?

When a table is wider than its container, the trailing edge is a hard cut, so the table looks complete when it isn't. Tables without actions have no cue at all, and the existing divider on the sticky actions column was missing in RTL and could go stale.

How?

  • Tables without actions: a sticky, zero-height overlay (the same pattern as the bulk actions toolbar) draws a gradient on the trailing edge of the visible area. Its height is written to the DOM on resize instead of re-rendering the table. These tables can't select rows and have no row tint, so one background color is always correct.
  • Tables with actions: the fade is a ::before on the sticky actions cells, shown with the existing --stuck class. It inherits each cell's own background and is masked to a gradient, so selected rows keep their tint. rtlcss doesn't flip mask-image, so the RTL value is set with an /*rtl:...*/ directive.
  • useScrollState:
    • It now tracks horizontal scroll for every table, not only tables with actions.
    • It measures again when the table or its container resizes, via useResizeObserver, instead of only on window resize. Before, adding columns from the view options didn't update the cue until the next scroll.
    • The scroll-end check now uses Math.abs( scrollLeft ) in both directions. In RTL, scrollLeft <= 1 reported the start of the scroll range as the end, so the actions divider was missing until you scrolled.

The overlay is aria-hidden and has pointer-events: none. Nothing changes in the accessibility tree or for focus.

Testing Instructions

  1. Run npm run storybook:dev and open DataViews > DataViews > Layout Table.
  2. Narrow the canvas until the table scrolls horizontally.
  3. Check that the columns fade out just before the sticky actions column, and that the fade goes away when you scroll to the end.
  4. Select a row and check that the fade keeps the row's selection tint.
  5. Switch the toolbar to RTL and repeat. The fade and the divider show at the start of the scroll range, on the left.
  6. Widen the canvas until every column fits and check that there's no fade.
  7. Run npm run test:unit:vitest -- packages/dataviews/src/dataviews/test/table-scroll-fade.browser.test.tsx to cover the table without actions, adding columns without scrolling, RTL, and the actions column.

Testing Instructions for Keyboard

  1. Tab into the table and through the row actions while the table overflows.
  2. Focus and keyboard behavior are unchanged, and the fade never blocks a focused control.

Screenshots or screencast

Before After
image image

Use of AI Tools

…crolled

Tables without actions get a sticky overlay that fades the trailing edge
of the visible area. Tables with actions fade the columns scrolling under
the sticky actions column, in each cell's own background so selected rows
keep their color.

The scroll state is now tracked for every table, measured again when the
table or its container resizes (not only on window resize), and the
scroll-end check now works in RTL, where it previously reported the start
of the scroll range as the end.
@github-actions github-actions Bot added the [Package] DataViews /packages/dataviews label Oct 29, 2026
@github-actions

github-actions Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

👋 Welcome

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @yaman-694! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

🎉 Props

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: yaman-694 <yamanzyan@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>
Co-authored-by: mattmiklic <mattmiklic@git.wordpress.org>
Co-authored-by: yashwin <yashwinpoojary@git.wordpress.org>

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


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

🏷️ Labels

This pull request needs exactly one label indicating its type, and has 0.

  • Required: any label starting with [Type].
  • Found: none.

Read more about Type labels in Gutenberg. If you cannot add labels yourself, a reviewer can do it for you.

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Oct 29, 2026
Table cells don't wrap their text, so a long description or caption ran
past its column and overlapped the next one. Both fields now truncate
with an ellipsis in the table layout, like the filename field, and keep
the full text in the DOM.
@yaman-694 yaman-694 changed the title DataViews: Show that a table has more columns to scroll DataViews: Show that a table has more columns to scroll, and stop long media descriptions overlapping Oct 29, 2026
@yaman-694 yaman-694 changed the title DataViews: Show that a table has more columns to scroll, and stop long media descriptions overlapping DataViews: Show that a table has more columns to scroll Oct 29, 2026
Size the scroll fade from a ref effect that observes its scroll container,
so a fade that mounts after the first render (when actions become empty)
gets its height. Inherit the background and mask it, like the sticky
actions column, so the fade matches the surface a consumer sets, and place
it with logical properties so it sits on the inline-end edge in RTL.

Track the container and the table with a single ResizeObserver in
useScrollState, which now only reports scroll state.

Drop the hand-written CHANGELOG entries, and extend the browser tests to
cover the late-mounting fade, the inherited color and the RTL position.
@yaman-694
yaman-694 marked this pull request as ready for review October 29, 2026 17:00
@jameskoster

Copy link
Copy Markdown
Contributor

@mattmiklic has been exploring something similar for wp-admin, we should align on the approach (which I believe this PR already does).

@jameskoster
jameskoster requested a review from a team November 12, 2026 19:41
@oandregal

Copy link
Copy Markdown
Member

I just came across this pr from the issue and asked design over there on the way forward. I'd like to clarify that before discussing implementation.

@oandregal

oandregal commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Thanks for the pr @yaman-694

I've prepared an alternate pr that uses a CSS only approach and deals with tables without actions (following suit on wp-admin approach). Would you mind consolidating over there?

@yaman-694

Copy link
Copy Markdown
Contributor Author

Sure @oandregal I will migrate my changes to your PR.

@oandregal

Copy link
Copy Markdown
Member

#86829 is ready and I'll merge soon. Thanks for trying this, Yaman.

@oandregal oandregal closed this Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] DataViews /packages/dataviews

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DataViews: Show that a table has more columns to scroll

3 participants