Tables: Use fixed layout depending on table width/number of columns#71189
Open
ocean90 wants to merge 5 commits intoWordPress:trunkfrom
Open
Tables: Use fixed layout depending on table width/number of columns#71189ocean90 wants to merge 5 commits intoWordPress:trunkfrom
ocean90 wants to merge 5 commits intoWordPress:trunkfrom
Conversation
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @robertbpugh. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
Closes #70454
We (@KarinChristen, @krokodok, @velthy, @ocean90) wanted to share an update in response to the discussion raised in issue #70454, where the focus has been on exposing the
hasFixedLayouttoggle in the Table block UI and improving default responsive behavior, especially for mobile and tablet views.Why?
Increasing the fixed-layout threshold for wide tables prevents cramped content and overlapping cells—especially important for spreadsheets or data-heavy tables.
By automating this threshold check, we reduce the need for authors to manually add media-query CSS for responsiveness.
For simpler tables (1–3 columns), the existing hasFixedLayout behaviour stays unchanged. We’re only targeting broader tables where fixed layouts start causing real issues on small screens.
In summary: We’ve built upon the idea from #70454—which seeks to improve the Table block’s responsiveness and flexibility—by adding rules tailored for wider, more complex tables. This ensures a stronger, mobile-friendly design without requiring manual overrides.
How?
We’ve extended the logic to better support complex tables—specifically, those with 4 or more columns—to ensure readability without breaking layouts on mobile:
We detect when a Table block has at least 4 (or 5) columns using selectors like
td:nth-of-type(4):last-of-type(ornth-of-type(5)).If the container width is at least 500px, we apply:
This enforces a minimum width (e.g. around 800px) for such complex tables, ensuring they remain legible.
On mobile devices, users will naturally see a horizontal scroll rather than broken or overlapped cells.
Testing Instructions
Copy the following blocks HTML into a page and resize the window to see how the layout changes.
Details
Testing Instructions for Keyboard
Screenshots or screencast