Skip to content

Give every value the direction of its own text - #194

Merged
pournasserian merged 5 commits into
mainfrom
172-text-direction
Dec 1, 2026
Merged

pournasserian merged 5 commits into
mainfrom
172-text-direction

Conversation

@pournasserian

@pournasserian pournasserian commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Text in the other direction gets one rule, written down first as decision record 0015, then applied to the stylesheet.

The record

  • A value isolates its text with unicode-bidi: plaintext: data of the host or words a person typed, whose language the library cannot know. A cell of a table, the value of a description list, the actions of a card, and the parts that hold a name or a title, with the parts that already did. Words of the interface (labels, headings of the navigation, segments, the titles of cards and disclosures, the choices of a select) follow the page and are not isolated; a host that puts a value there uses dir="auto".
  • A cut value loses its own end: an English title in a right-to-left page is cut at the right, an Arabic name in a left-to-right page at the left. Its beginning always shows.
  • A value is aligned by its own direction, as dir="auto" does: a short English title in a right-to-left cell sits at the left. The record says why (an inline wrapper in every cell would change the markup of every part, and cutting the beginning of a title is the worse fault) and how a host keeps one edge for a column.

What was measured to decide it is in the record: without isolation, an English title in a right-to-left box loses its beginning and draws its question mark first; text-align: match-parent does not keep a short value on the page's edge in Chromium; an element with dir="auto" alone inside an isolated cell does not either.

The stylesheet

The rule goes on the box that holds the text, never on a box that can hold only a number, a badge or a control: such a box takes left to right and leaves its place in the page. So:

  • unicode-bidi: plaintext on the elements in a cell of fl-table (but its title and meta blocks) and on the elements in those two; the cell keeps the page's direction, so a number stays at the end of its column and a badge at its start;
  • on the elements in the dd of a description list, and on the children of fl-card__actions;
  • on the 4 parts that cut a name or a title with an ellipsis, fit it, and did not have it: the tag of a combobox, the site name of the navigation, a tag, the title of a page header.

Every part that cuts its text was looked at. The parts of the interface (navigation labels and heading, segments, the titles of cards and disclosures, the bar note, the select), the form controls (an input, the field of a combobox) and the boxes that stretch across their row (an item of a tree, an option of a combobox, the text beside an avatar, the name of a file) follow the page. For the last group the record says the cost: a long English name there in a right-to-left page is cut at its beginning, since a stretched box with plaintext takes a short name to the far end of its row, away from its icon, as the first CI run of this pull request showed in the tree. RECIPE section 7 states the rule.

Decisions

  • Isolation by plaintext on the part, not a wrapper and not a parameter: the record weighs the three.
  • Alignment by the value's own direction is accepted, as the price of the rule; the record says how a host keeps one edge.
  • The line between a value and a word of the interface is drawn per part in the record, so that the English words of a right-to-left page of this gallery keep the page's direction where they are the interface.

Tests

Foundations/TextDirectionTests, one test per rule, each putting an English title into a right-to-left page and an Arabic one into a left-to-right page, in static rendering (the text is put in by script):

  • AValueKeepsTheOrderOfItsOwnText: a table title link and an element of its meta line, an element of a description list value, a link among the actions of a card and a tag: the last character of the value is drawn after its first in its own direction.
  • AStretchedLabelKeepsItsTextAtTheStartOfItsRow: a short English name in a right-to-left tree stays at the start of its row.
  • ACellKeepsThePlaceOfWhatItHoldsInThePagesDirection: in a right-to-left table, a number stays at the end of its column, and a badge and the link of a title in the page's language at the start of their cells.
  • ACutValueLosesItsOwnEnd: at 320 pixels, the page header title, the current level of a breadcrumb (which had the rule already) and a tag are cut, and their first character is in view.

Without the stylesheet change the first two fail on every part but the breadcrumb (checked on the base branch); the third failed on the first version of this pull request, which isolated whole cells. All three pass.

Command Result
dotnet build -c Release -warnaserror 0 warnings, 0 errors
dotnet test --project tests/FluentCMS.Components.Tests 797 passed
dotnet test --project tests/FluentCMS.Components.Browser --filter-namespace ...Foundations --filter-namespace ...Data --filter-namespace ...Layout --filter-namespace ...Navigation (three modes) 598 of 600; Layout.DisclosureRoundTripTests.EarlierAcknowledgementsCannotUndoLaterNativeToggles(Server) failed once in the full run and passed 5 of 5 alone (the disclosure is not changed here)
node design/tools/contrast.mjs 129 pairs, 0 failed
npx --yes markdownlint-cli2@0.24.2 "**/*.md" 0 issues

Not run locally: Firefox and WebKit (nightly), the visual job (CI only).

Visual baselines

The light captures should not change: a value in the page's own language is laid out as before. The dark-compact-rtl captures change where a part holds English text in a right-to-left page: it is now laid out left to right and, where it is short, sits at the left. Each changed capture is reviewed from the CI artifact.

Closes #172

@pournasserian

Copy link
Copy Markdown
Member Author

Review by a fresh reviewer (diff and issue only), and what became of each point. Fixed in fc1817c.

  1. Must fix: plaintext on a table cell moved what has no strong character. Confirmed in Chromium on a bare page: a right-to-left cell with plaintext drew a number ("1,234") at the right with text-align: end, where the numbers of a column are at the left, and a cell that held only a badge or a <bdi>, Arabic inside, put it at the left. The cell itself is no longer isolated; the elements in it are, as dir="auto" does, and so are the elements in its title and its line of meta. The title and meta blocks keep the page's direction too, since a block that holds only a link (an atomic box) would take left to right in the same way; a new test caught that one.
  2. Must fix: the same on dd and on the actions of a card. The dd keeps the page's direction and its elements are isolated; the actions keep only the rule on their children.
  3. The tests did not cover the native case. New ACellKeepsThePlaceOfWhatItHoldsInThePagesDirection: in a right-to-left table, a number stays at the end of its column, and a badge and the link of a title in the page's language stay at the start of their cells. It failed on the first version, on the title, before the fix above.
  4. Form controls. plaintext on an input would put the caret of an empty field at the other end and move a number away from the end of its box. The input and the field of a combobox follow the page; the record tells a host to set dir="auto" on a field that takes text in either direction.
  5. Record and CSS agree on every part that cuts with an ellipsis; the record now also says why a container that can hold only a number, a badge or a control is never isolated, with what was measured.
  6. The baselines are taken from this pull request's CI run and reviewed before they are committed.

After the fix: TextDirectionTests, 3 passed (the two rules, both directions, and the native case); markdownlint, 0 issues.

@pournasserian

pournasserian commented Dec 1, 2026 •

Copy link
Copy Markdown
Member Author

The first visual run showed a fault of this pull request, before any baseline was taken: in right to left, every label of a tree went to the far end of its row, away from its icon, with the count against it. A box that stretches across its row (an item of a tree, an option of a combobox, the text beside an avatar, the name of a file) takes a short text to its far end under plaintext. Those four now keep the page's direction (d94c633); the record says the cost (a long English name there is cut at its beginning in a right-to-left page), and AStretchedLabelKeepsItsTextAtTheStartOfItsRow checks the tree. The server job's only failure on that run, ContentListTests.SortHeaders…, is the router-focus race of #182 in another test; it is not caused by this change and is being routed separately.

@pournasserian

Copy link
Copy Markdown
Member Author

Visual baselines, taken from run 46582460046 (on d94c633) and reviewed one by one; committed in db1c3eb. Only the five dark-compact-rtl captures changed, each as intended:

  • table/table-states-1: the English empty message now ends with its full stop ("…all reviews.") instead of starting with it.
  • tag/wrap-1: the long English tag is cut at its own end ("A label that is … so …") instead of its beginning.
  • patterns/page-header-1: the English title is cut at its own end ("What's new in the spring release: our guide to …").
  • dashboard/content and dashboard/window: the action of the Translation coverage card reads "18 missing" instead of "missing 18". Nothing else moved: trees, avatar text, file names, numbers and badges keep their places.

No other capture in the three themes changed.

@pournasserian
pournasserian merged commit 4477e42 into main Dec 1, 2026
8 checks passed
@pournasserian
pournasserian deleted the 172-text-direction branch December 1, 2026 12:25
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.

Right to left: decide which parts isolate their text and where a truncated text ends

1 participant