Skip to content

Added max-width to DataView columns #70983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

rcrdortiz
Copy link
Contributor

@rcrdortiz rcrdortiz commented Jul 30, 2025

What?

We're adding a max-width to DataView columns to avoid having infinite-length columns.

Why?

The UI for Table DataViews looks broken when a field is really large, the text doesn't get split into multiple lines and we need to scroll to the end to see other columns.

How?

We're adding a max-width to the cells in the DataView's Table Layout.

Testing Instructions

Testing Instructions for Keyboard

Screenshots or screencast

Before After
Screenshot 2025-07-30 at 15 50 32 Screenshot 2025-07-30 at 15 44 30

@rcrdortiz rcrdortiz requested a review from oandregal as a code owner July 30, 2025 13:45
Copy link

github-actions bot commented Jul 30, 2025

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: rcrdortiz <rcrdortiz@git.wordpress.org>
Co-authored-by: youknowriad <youknowriad@git.wordpress.org>
Co-authored-by: oandregal <oandregal@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>

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

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 30, 2025
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @rcrdortiz! 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.

@t-hamano t-hamano added [Type] Bug An existing feature does not function as intended [Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond [Package] DataViews /packages/dataviews labels Jul 31, 2025
@youknowriad
Copy link
Contributor

Looks like you committed your personal .idea folder. You might want to consider gitexcluding that in your own global gitignore :)

@youknowriad
Copy link
Contributor

Did you forget adding the fixes (the actual maxWidths...), I don't see it in the diff?

@rcrdortiz
Copy link
Contributor Author

Did you forget adding the fixes (the actual maxWidths...), I don't see it in the diff?

It got deleted on my second commit, restored the actual fix.

@rcrdortiz
Copy link
Contributor Author

Looks like you committed your personal .idea folder. You might want to consider gitexcluding that in your own global gitignore :)

Yup, thanks for the tip!

@youknowriad
Copy link
Contributor

Let's add a dataviews CHANGELOG entry about this change. :)

@youknowriad
Copy link
Contributor

youknowriad commented Jul 31, 2025

Screenshot 2025-07-31 at 11 55 52 AM

If you check the "Templates" DataViews in the site editor, you'll notice the following:

  • It has specific styles targeting .page-templates-description to apply something very similar to the generic fix being applied here. (this style should probably be removed)
  • If you remove that specific style, the generic fix doesn't work properly all the time (see screenshot). I believe that's because there's not enough fields so the column is large anyway. I wonder if there's a better way to make this fix apply more generically (maybe by targeting the field wrappers rather than "td", at least for the "primary column" maybe if it's not possible for all fields)

What do you think ?

@youknowriad youknowriad requested a review from jameskoster July 31, 2025 11:57
@rcrdortiz
Copy link
Contributor Author

Here is a video with what the Table Layout looks like with the most recent changes:

latest-table-layout.mp4

@jameskoster
Copy link
Contributor

maybe by targeting the field wrappers rather than "td",

I think this is worth a try. td doesn't respect min-width and max-width very accurately, which seems reasonably important if we want to optimise for legibility (50-75 chars per line including spaces). That's why we ended up with the template description approach.

@rcrdortiz
Copy link
Contributor Author

I've just pushed some changes that remove the custom class and styles that the Templates DataView had. I still need to figure out what's making the Authors column that wide, but I think it's a step in the right direction. Here is a screenshot of the changes.

Screenshot 2025-07-31 at 17 07 05

…use more space when the Table layout view has fewer fields
@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Jul 31, 2025

Okay, I've progressed more, but I'm trying to figure out what the best approach is now.

I can keep the nowrap for non-primary column cells. This approach looks best in most cases except when we have cells with really long text; in that case, the length of the cell will be the same as the length of the text. Here are some examples:

nowrap-templates.mp4
nowrap-storybook.mp4

This here is the main issue with not wrapping text:

nowrap-issue.mp4

When we wrap text, large tables become somewhat easier to read, and are better suited (marginally) to the available screen's real estate without requiring scrolling as much, and we avoid having long cells. The problem is that wrapping kicks in soon once we have a few fields. Here are some examples:

wrap-templates.mp4
wrapping-storybook.mp4

I think I'm more inclined towards the nowrap approach, but we wouldn't be solving the main issue. If we have cells with large chunks of text, the table will look just as bad as it does now. I'm not sure if the changes I've made to the primary column are a good enough tradeoff.

What do you all think?

@youknowriad youknowriad force-pushed the fix/dataviews-automatic-max-width-for-columns branch from 5c47188 to 2510737 Compare August 1, 2025 09:01
@youknowriad
Copy link
Contributor

@rcrdortiz I noticed that the approach was not working properly for primary columns (templates example). The columns was still increasing width as the size of the screen increased. The issue was that max/min width don't work well on td, th. Instead I pushed an alternative approach where I applied the min/max widths to the divs within the cells instead. Let me know what you think.

@oandregal
Copy link
Member

Hey, there's some issue with the media field in this PR:

Trunk This PR
Screenshot 2025-08-01 at 11 11 42 Screenshot 2025-08-01 at 11 16 13

Co-authored-by: André <583546+oandregal@users.noreply.github.com>
@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Aug 1, 2025

Hey, there's some issue with the media field in this PR:

Trunk This PR
Screenshot 2025-08-01 at 11 11 42 Screenshot 2025-08-01 at 11 16 13

I'll have a look at @youknowriad changes and fix the issue.

Update: Fixed the issue by excluding the media part of the primary column from having a min-width.

@rcrdortiz
Copy link
Contributor Author

rcrdortiz commented Aug 1, 2025

IMHO, the max-width: 60ch doesn't look good in cases when there is a lot of space available. For example, the templates screen looks off:

looks-off.mp4

90ch, on the other hand, makes the experience somewhat more pleasing:
Screenshot 2025-08-01 at 11 47 03

I'll change the max-width from 60 to 90. @youknowriad @jameskoster, please let me know if you have any complaints about it.

@youknowriad
Copy link
Contributor

I'll defer to @jameskoster about this, I've just used something that is closed to what we had before.

@rcrdortiz
Copy link
Contributor Author

I'll defer to @jameskoster about this, I've just used something that is closed to what we had before.

Fair enough, feel free to merge the changes once we get confirmation from @jameskoster.

@jameskoster
Copy link
Contributor

I agree the empty space isn't ideal at a glance, but when it comes to actually reading the text, the narrower version is more widely legible, and that is what we should optimise for imo. 50-75 characters per line is a rule of thumb though. WCAG guidelines are to avoid exceeding 80, so I'd be happy with 80 or below.

@youknowriad youknowriad enabled auto-merge (squash) August 1, 2025 14:41
@youknowriad youknowriad merged commit 2e5d6bc into WordPress:trunk Aug 1, 2025
59 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.4 milestone Aug 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] DataViews Work surrounding upgrading and evolving views in the site editor and beyond First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] DataViews /packages/dataviews [Type] Bug An existing feature does not function as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants