Repository navigation
[site] Let docs tables scroll horizontally instead of overflowing on narrow screens - #1489
Open
ngocanhnckh wants to merge 1 commit into
Open
ngocanhnckh wants to merge 1 commit into
ngocanhnckh wants to merge 1 commit into
Conversation
…narrow screens Tables in docs pages can contain content that cannot wrap (code, long identifiers), so on narrow viewports they were wider than the article and either stretched the page or were cut off. Make top-level tables horizontally scrollable, sized to their content and capped at the article width. Tables with a .wide-cell still fill the article. Fixes lit#1293
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.
Fixes #1293
What is broken
Tables in the docs are wider than the article column on narrow screens and nothing scrolls, so the right-hand column is cut off or the whole page scrolls sideways.
/docs/components/properties/, the two "Type Conversion" tables: 380px and 404px wide inside a 272-327px column at 320-375px./docs/templates/directives/(the issue in Page at /docs/templates/directives/ does not seem responsive to thinner displays #1293): the signature tables are up to 783px wide and stick out of the article at every phone width and also at 768px.Root cause
tableindocs.cssis a normal table, so it can't be narrower than its widest unbreakable content (code such asJSON.stringify(propertyValue)or a directive signature). Nothing in the article lets it scroll.Fix
In
docs.css, top-level tables becomedisplay: block; width: max-content; max-width: 100%; overflow-x: auto: they keep the width of their content when it fits, are capped at the article width and scroll horizontally when it doesn't. Tables with a.wide-cell(the directives tables) keep filling the article viatable:has(.wide-cell) { width: 100% }. Tables nested inside another table's cell are left alone.The footer social-links overflow is a separate bug (open PR #1447) and is not touched here, so a small footer-caused overflow remains below ~460px.
Testing
npm run dev, Chromium via Playwright, widths 320, 375, 414, 768, 820, 1024, 1280, 1440, light and dark.scrollWidthon 13 docs pages with tables: tables no longer widen the page at any width; what remains at 320-414px is the footer (same value as on a page with no tables).npx prettier --checkondocs.csspasses. The repo's screenshot tests only pass on the CI runner, so I did not run them.The red boxes in the before shots mark the broken part.
I found this with renderlint, an open-source CLI I maintain that renders pages in a headless browser and reports layout defects. It flagged the tables as
viewport-overflow/content-overflowbefore the change and no longer does after it (it does now report a few-pixelaccidental-scrollbaron two tables that are only 1-8px wider than the article, which is expected for a scroll container). If it would be useful, I'm happy to open a follow-up PR that runs it on the docs in CI; no pressure either way.