Skip to content

Scroll wide tables in a box of their own - #223

Open
eric-schneider wants to merge 1 commit into
mainfrom
t10-wide-tables
Open

eric-schneider wants to merge 1 commit into
mainfrom
t10-wide-tables

Conversation

@eric-schneider

Copy link
Copy Markdown
Contributor

A table wider than the column makes the whole page scroll sideways: on a phone that happens with many tables, and on desktop with the widest reference tables. docs-ui's scrolltable role never helped, since a table ignores overflow-x, so this drops its rule: a table with the role scrolls in its box like any other.

This PR puts each table in an article in a box that scrolls sideways on its own, so the page doesn't:

  • A short script, 09-table-scroll.js, wraps each table in a div.tablecontainer. Asciidoctor Tabs gives that class to the box it puts around the tables in tab panels, which now scrolls too, and the table margin rules in doc.css already expect it, so tables keep their spacing. Tables in other tables' cells, and tables floated by the left or right role, aren't boxed; a table in an admonition is, though Asciidoctor lays out admonitions as tables too.
  • While a table doesn't fit, its box is a region that the keyboard can reach and scroll, with a focus ring. When focus scrolls a tall box into view, a scroll margin keeps its top below the fixed header, as long as the top was on screen.
  • The region is named by the table's caption, or else by the heading of its section, or by the page title before the first section, with a number only when a heading has more than one untitled table. Asciidoctor numbers only titled tables, so a name by position could echo another table's caption.
  • Since macOS and iOS hide scroll bars, the box fades out at each edge that has more of the table behind it, over as much as is hidden, up to 32 px.
  • A table that fits doesn't change.
  • In print the box neither scrolls nor fades, and words in tables break where needed so that whole tables fit the page. That can also break a long word in a narrow column, and in a table much wider than the page, even short words in narrow columns.

On a phone:

wide-table-phone-before-after(3)

With the keyboard on desktop:

wide-table-keyboard-before-after(2)

In print:

wide-table-print-before-after(2)

It also brings back word breaking for the article, which docs-ui dropped in #61, so a long word in its text breaks where it can't fit its line, as does a long property path in a CRD reference's section headings:

long-heading-before-after(3)

Upstream breaks words with word-wrap: anywhere on the whole page (96d0998). This uses break-word on the article instead, since anywhere also lets flex items, such as wrapped tab titles, shrink below their longest word and break mid-word. But break-word keeps a flex item at least as wide as its longest word, so section headings and image titles, whose text is a single flex item in docs-ui's layout, use anywhere. A step's number keeps normal wrapping, since it's a flex item of its own beside the heading's text, which anywhere would break between the number and its period. The page title and collapsible block summaries stay as they are: with inline markup, their text is several flex items, which anywhere would break mid-word. In tables, text keeps normal wrapping, as in 96d0998, and code keeps its own. Upstream's later word breaking in AsciiDoc table cells (6099a87) stays out, since it breaks words mid-word and shrinks short tables.

Size changes: site.css grows by 2,158 bytes, 286 gzipped, and site.js by 2,173 bytes, 766 gzipped; the fonts don't change.

A table wider than the column made the whole page scroll sideways, on
a phone and, for the widest tables, on desktop. The scrolltable role
never helped, since a table ignores overflow-x, so its rule goes: a
table with the role now scrolls in its box like any other.

A short script now puts each table in an article in a
div.tablecontainer that scrolls sideways on its own, so the page
doesn't. Asciidoctor Tabs gives that class to the box it puts around
the tables in tab panels, which now scrolls too, and the table margin
rules in doc.css already expect it. Tables in other tables' cells,
and tables floated by the left or right role, aren't boxed; a table
in an admonition is, though Asciidoctor lays out admonitions as
tables too.

While a table doesn't fit, its box is a region the keyboard can reach
and scroll, and it fades out at each edge with more of the table
behind it, since macOS and iOS hide scroll bars. When focus scrolls a
tall box into view, a scroll margin keeps its top below the fixed
header, as long as the top was on screen. A table that fits doesn't
change.

The region is named by the table's caption, or else by the heading of
its section, or by the page title before the first section, with a
number only when a heading has more than one untitled table.
Asciidoctor numbers only titled tables, so a name by position could
echo another table's caption.

In print the box neither scrolls nor fades, and words in tables break
where needed so that whole tables fit the page. That can also break a
long word in a narrow column, and in a table much wider than the
page, even short words in narrow columns.

This also brings back word breaking for the article, which docs-ui
dropped in #61: a long word in its text breaks where it can't fit its
line. It uses break-word rather than the anywhere of upstream's
96d0998, which would also let flex items, such as wrapped tab titles,
shrink below their longest word. But break-word keeps a flex item at
least as wide as its longest word, so section headings and image
titles, whose text is a single flex item, use anywhere: a long
property path in a reference heading no longer pushes the page
sideways. A step's number keeps normal wrapping, since it's a flex
item of its own beside the heading's text, which anywhere would break
between the number and its period. The page title and summaries keep
break-word, since with inline markup their text is several flex items.
In tables, text keeps normal wrapping, as in 96d0998, and code keeps
its own.
@eric-schneider eric-schneider self-assigned this Nov 24, 2026
@github-actions

github-actions Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

UI bundle preview build successful! ✅
Deploying bundle preview.
Deploy successful! View preview

@eric-schneider

eric-schneider commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

Build successful! ✅
Deploying draft.
Deploy successful! View draft

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant