Repository navigation
Conversation
…he keyboard Text's truncation tooltip anchored to an element that never took focus, so sighted keyboard users could not reveal clipped text (Text FR4, WCAG 2.1.1). While measured as truncated with its tooltip on, Text now takes tabIndex=0, which gives Tooltip its focus trigger; a Text inside a control that already takes focus (link, button, menu item, option, grid row or cell) stays out of the tab order. Text.spec.md narrows the FR4 gap and Current-state bullet to the nested case.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Making a truncated Text a tab stop is the right fix for its keyboard gap, but this can't be approved yet: it rewrites the current component:Text FR4 (a tab stop, with no tab stop inside a link, button, menu item, option, or grid row or cell), so an engineering owner needs to record that decision by commenting /approve-spec b4fd31ba1ab35017db8187ff91ccee09128f7301 on this pull request, and the author may do so as an engineering owner. Whatever the decision, two fixes are needed:
CONTROL_SELECTORtreats any ancestor with atabindexas a control, so a truncated Text insideAppShell's main region (tabIndex={-1}), aDrawerbody or a chat log never becomes a tab stop; match only interactive elements and widget roles, and add a test for a Text inside atabindexregion.- The constant sits between
Text's JSDoc and the function, soTextloses its doc comment; move it above the comment.
[Automated review]
The ancestor check matched any element with a tabindex, so a truncated Text inside AppShell's main region, a Drawer body, a chat log or a scrollable table viewport never became a tab stop. It now matches only interactive elements and widget roles. The selector sits above Text's doc comment so the JSDoc stays on Text. A test covers a Text inside a focusable region.
There was a problem hiding this comment.
Making a truncated Text a tab stop fixes its keyboard gap, and the latest commit resolves the earlier AppShell and doc-comment problems, but approval still waits on an engineering owner's decision on the new FR4 requirement (a tab stop, except inside a control that takes focus or acts as one item): an engineering owner records it by commenting /approve-spec 3c783767d1dd88a06eff3c41fbb1a4d6a9805ebb on this pull request, and the author may do so as one. Whatever the decision, two things need fixing:
- A truncated title inside a
ClickableCardbecomes a second tab stop in the card, with the card outline and the text's own ring showing together; treat the card surface as one item (checked once the tooltip turns on, since the card marks its root in an effect) or have an owner rule otherwise, and add a test. - Focus on the new tab stop reads the full text twice until the separate fix that drops the tooltip's
aria-describedbylands, so merge after it.
[Automated review]
The control check ran once on attach, before ClickableCard's passive effect marks its surface as pressable, so a cut title inside a clickable card became a second tab stop with two focus rings. The check now runs when the tooltip turns on (always after mount), treats a pressable container as a control, and sets the tab stop on the element directly; a caller's tabIndex still wins. Text.spec.md's compatibility rows name the new tabindex.
There was a problem hiding this comment.
Making a truncated Text a tab stop closes its FR4 keyboard gap, and the latest commits fix the ClickableCard double stop and the stale compatibility rows, but approval waits on an engineering owner's decision on the new FR4 requirement (a tab stop, except inside a control that takes focus or acts as one item): an engineering owner records it by commenting /approve-spec 3467d57337003f585448902f2481a559383f9be3 on this pull request, and the author may do so as one. Whatever the decision, these need fixing:
- Because the tab stop is now written in a passive effect, a
Texttruncated after the tooltip module has loaded becomes a tab stop whose tooltip never opens, sinceTooltipattaches first and sees an unfocusable element; renderingtabIndexfrom state, with the tooltip mounted after the check, fixes it. - The effect's cleanup removes a
tabIndexthe caller passes after truncation, and anaschange leaves the new element without a tab stop. [data-pressable-container]also matches everyOverlay, so a cut caption in a non-interactive Overlay gets no tab stop.
[Automated review]
… says so by context - The tab stop renders as tabIndex, so it is in the DOM before the tooltip attaches its focus trigger (an imperative attribute set after the tooltip's layout effect left it with no focus listeners when the tooltip module was already loaded), and a caller's tabIndex passed later still wins. - ClickableCard provides TextFocusOwnerContext around its content: its hidden control takes focus for the whole card, so a truncated title adds no second stop. Text no longer reads the pressable-container marker, which non-interactive Overlays also carry. - Tests: a caller tabIndex after truncation, a marked overlay keeps the stop, a real ClickableCard adds none.
There was a problem hiding this comment.
Making a truncated Text a tab stop now opens its tooltip from the keyboard on every timing path, and the latest commit fixes the passive-effect, late-tabIndex and Overlay problems, but approval still waits on an engineering owner's decision on the new FR4 requirement (a tab stop, except inside a control that takes focus or acts as one item): an engineering owner records it by commenting /approve-spec 94dc0b366083ff16f2bf334b255bbd22088c0dc7 on this pull request, and the author may do so as one. Whatever the decision, these need fixing:
- A cut
Textinside aSelectableCard,CheckboxListItemorRadioListItemnow becomes a second tab stop, because their hidden checkbox or radio sits beside the content rather than around it; providingTextFocusOwnerContextfrom those components too, with a nested-control test for each, keeps one stop per item. - The record says no default changed (
Text.spec.mdlines 40 and 55) while the changeset names a new default; make the two agree.
[Automated review]
…ncated Text too SelectableCard (its hidden checkbox) and every interactive Item (its row, or the delegate input CheckboxListItem and RadioListItem pass as interactiveRef) provide TextFocusOwnerContext, so a truncated Text in a card, a checkbox option or a radio option adds no second tab stop (CheckboxListItem FR1, RadioListItem FR4). A non-interactive Item leaves the surrounding value alone. The truncation tests find the Text element itself, since the mounted tooltip repeats its text.
There was a problem hiding this comment.
Making a truncated Text a tab stop opens its tooltip from the keyboard, and the latest commit keeps one stop per SelectableCard, CheckboxListItem and RadioListItem, but approval still waits on an engineering owner's decision on the new FR4 requirement (a tab stop, except inside a control that takes focus or acts as one item): an engineering owner records it by commenting /approve-spec cd899e7be33e696199663a72614dc3f801df0720 on this pull request, and the author may do so as one. Whatever the decision, these need fixing:
MaybeTextFocusOwnerinItem.tsxfails thelintcheck (promise-function-async) and remounts a row's content wheneveronClick,hreforinteractiveRefchanges; rendering the provider unconditionally withvalue={isInteractive || inherited}fixes both.- A cut
Textinside a Dialog or Popover opened from an interactive row or card gets no tab stop because the context reaches the overlay; reset it at overlay roots and add a test. - The record says no default changed (
Text.spec.mdlines 40 and 55) while the changeset names a new default; make the two agree.
[Automated review]
…des it; the record says the default changed
- TextFocusOwnerContext is layer-scoped, so a Dialog, Popover or other
layer opened from a card or an interactive row gives its truncated Text
its own tab stops.
- Item renders the provider unconditionally (its value or the inherited
one), so adding or removing onClick, href or interactiveRef no longer
remounts the row's content, and strict lint passes.
- Text.spec.md's compatibility rows say the released default changes
(a truncated Text is a tab stop) and that tabIndex={-1} keeps the old
behavior, matching the changeset.
There was a problem hiding this comment.
Making a truncated Text a tab stop opens its tooltip from the keyboard, and the latest commit fixes the Item lint and remount problems and gives a Dialog or Popover opened from a card or row its own stops, but approval still waits on an engineering owner's decision on the new FR4 requirement (a tab stop, except inside a control that takes focus or acts as one item): an engineering owner records it by commenting /approve-spec 88eaf7cf208d729d7b3b110fc963fc846ccadba6 on this pull request, and the author may do so as one. Whatever the decision, these need attention:
Text.spec.mdline 57 still says "no public prop, default, or styling change" (and Builder impact says "None") while line 55 and the changeset say the default tab order changes.- The header and
SYNC:list inTextFocusOwnerContext.tsname onlyClickableCard, thoughItemandSelectableCardprovide it too. - Merge after the fix that stops the tooltip describing
Text;mainstill sets thataria-describedby.
For the decision: each cut cell in a textOverflow="truncate" Table becomes its own tab stop, and the focused text shows the browser's default focus ring rather than the shared outline.
[Automated review]
There was a problem hiding this comment.
Making a truncated Text a tab stop closes the keyboard gap that component:Text FR4 names, and CI checks pass. Approval waits on an engineering owner's decision on the new FR4 requirement (a truncated Text is a tab stop unless it sits inside a control that takes focus or acts as one item), recorded by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner, and rejecting it keeps FR4's current text. Independently of that decision, one fix is needed:
- A truncated Text inside an
aria-hidden="true"subtree still becomes a tab stop (Text.tsx327–333), so keyboard focus can land on hidden content, as in Lab EmojiPicker's preview footer at narrow widths; skip the stop there and add a test. - Consider noting keyboard focus and the
tabIndex={-1}opt-out in themaxLinesandhasTruncateTooltiprows ofText.doc.mjs. - Merge after the fix that stops the truncation tooltip from describing Text, which is not on
mainyet.
[Automated review]
…b stop A truncated Text inside (or itself carrying) aria-hidden="true" or inert takes no tabindex, so keyboard focus never lands on content a screen reader cannot perceive (Lab EmojiPicker's preview footer at narrow widths). Test beside the control cases.
There was a problem hiding this comment.
Making a truncated Text a tab stop closes the keyboard gap that component:Text FR4 names, and the latest commit keeps focus out of aria-hidden and inert content. Approval waits on an engineering owner's decision on the new FR4 requirement (a truncated Text is a tab stop unless it sits inside a control that takes focus or acts as one item), recorded by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner, and rejecting it keeps FR4's current text. Independently of that decision:
- The hidden-content check runs only when the Text attaches (
Text.tsx332–339), so a cut Text that mounts inside a closed controlledOverlayor a collapsedChatComposerDrawerstays out of the tab order after it opens; re-run the check when that ancestor'saria-hiddenorinertchanges, with a test that removes it after mount. - Consider noting keyboard focus and the
tabIndex={-1}opt-out in themaxLinesandhasTruncateTooltiprows ofText.doc.mjs. - Merge after the fix that stops the truncation tooltip from describing Text, and take
maininto the branch so thebuild-storybookstory-tree check, which passes onmain, runs on current story titles.
[Automated review]
The hidden check ran only when the Text attached, so a truncated caption mounted under a closed Overlay's inert scrim or a collapsed drawer stayed without a stop after it opened. Text now watches each aria-hidden or inert ancestor it found and re-checks when that attribute changes; a test removes both after mount.
There was a problem hiding this comment.
Making a truncated Text a tab stop closes the keyboard gap that component:Text FR4 names, and the latest commit gives cut text revealed after mount its stop back. Approval waits on an engineering owner's decision on the new FR4 requirement (a truncated Text is a tab stop unless it sits inside a control that takes focus or acts as one item), recorded by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner, and rejecting it keeps FR4's current text. Independently of that decision:
- A cut Text that is measured while hidden and revealed later (a controlled
Overlaythat opens, for one) now takes focus but never opens its tooltip, becauseTooltipattached its focus trigger while the text was unfocusable (useTooltip.tsx507–515); re-attach it when the stop appears, for example withfocusTrigger={isTabStop ? 'always' : 'auto'}, and have the test atText.test.tsx553 focus the text and expect its tooltip. - Consider noting keyboard focus and the
tabIndex={-1}opt-out in themaxLinesandhasTruncateTooltiprows ofText.doc.mjs. - Merge after the fix that stops the truncation tooltip from describing Text, which is not on
mainyet.
[Automated review]
…cus trigger useTooltip decides once, when it attaches, whether to listen for focus, so a revealed Text took focus but never opened its tooltip. Text passes focusTrigger 'always' while it is the tab stop (and no caller tabIndex decides), which re-attaches the trigger with focus listeners. The test focuses the revealed text and waits for its tooltip to open.
There was a problem hiding this comment.
Making a truncated Text a tab stop closes the keyboard gap that component:Text FR4 names, and the latest commit makes cut text revealed after mount open its tooltip on focus. Approval waits on an engineering owner's decision on the new FR4 requirement (a truncated Text is a tab stop unless it sits inside a control that takes focus or acts as one item), recorded by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner, and rejecting it keeps FR4's current text. Independently of that decision:
- Consider noting keyboard focus and the
tabIndex={-1}opt-out in themaxLinesandhasTruncateTooltiprows ofText.doc.mjs. - Merge after the fix that stops the truncation tooltip from describing Text, which is not on
mainyet.
[Automated review]
…s on keyboard focus too
There was a problem hiding this comment.
Making a truncated Text a tab stop closes the keyboard gap that component:Text FR4 names, and the latest commit updates the maxLines and hasTruncateTooltip docs to say the tooltip opens on keyboard focus. Approval waits on an engineering owner's decision on the new FR4 requirement (a truncated Text is a tab stop unless it sits inside a control that takes focus or acts as one item), recorded by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner, and rejecting it keeps FR4's current text. Independently of that decision:
- Consider naming the in-control exception and the
tabIndex={-1}opt-out in themaxLinesrow ofText.doc.mjs. - Merge after the fix that stops the truncation tooltip from describing Text, which is not on
mainyet.
[Automated review]
…n-control exception
Text's record moved to docs/specs/components/Text; FR3's reflow claim
and its verification row come from main, FR4's tab stop and its row
from this branch, and the compatibility lines carry both changes. Item
keeps main's clickable-container proxy and ListRow context inside the
focus-owner context. The maxLines doc names the in-control exception and
the tabIndex={-1} opt-out, per review.
…abIndex={-1} opt-out
Per review. (Meant for the previous commit.)
There was a problem hiding this comment.
Making a truncated Text a tab stop closes the keyboard gap that component:Text FR4 names, and the new tests fail before this change and pass after it. Approval waits on an engineering owner's decision on the new FR4 requirement: a truncated Text is a tab stop unless it sits inside a control that takes focus or acts as one item. An engineering owner records that decision by commenting /approve-spec <full head SHA> on this pull request, and the author may do so as an engineering owner; rejecting it keeps FR4's current text.
Blocking:
- Miss:
CONTROL_SELECTORinpackages/core/src/Text/Text.tsx(225–247) hand-rolls a second list of interactive controls beside the sharedINTERACTIVE_SELECTORSandinnermostInteractiveinpackages/core/src/hooks/useClickableContainer.ts, so extend that owner with a focus-owner predicate (without the pressable-container marker, plus the composite-item roles) and call it once from Text.
Please also merge only after the fix that stops the tooltip describing Text, or a focused cut Text is read twice.
[Automated review]
| const CONTROL_SELECTOR = [ | ||
| 'a[href]', | ||
| 'area[href]', | ||
| 'button', | ||
| 'input', | ||
| 'select', | ||
| 'textarea', | ||
| 'summary', | ||
| '[contenteditable]:not([contenteditable="false"])', | ||
| '[role="button"]', | ||
| '[role="link"]', | ||
| '[role="menuitem"]', | ||
| '[role="menuitemcheckbox"]', | ||
| '[role="menuitemradio"]', | ||
| '[role="option"]', | ||
| '[role="tab"]', | ||
| '[role="treeitem"]', | ||
| '[role="gridcell"]', | ||
| '[role="row"]', | ||
| '[role="switch"]', | ||
| '[role="checkbox"]', | ||
| '[role="radio"]', | ||
| ].join(', '); |
There was a problem hiding this comment.
This is a second hand-rolled list of interactive controls. hooks/useClickableContainer.ts already owns that concern: INTERACTIVE_SELECTORS (50–69) is documented as the one definition other focus and interaction utilities share "rather than hand-rolling divergent lists", and innermostInteractive (91) takes a custom predicate. The two lists share 12 entries and already differ (row, gridcell, treeitem, menuitemcheckbox, menuitemradio, summary and contenteditable here; combobox, listbox, slider, spinbutton and the pressable marker there), so a role fixed in one misses the other. Suggest adding a focus-owner predicate to the shared owner (its list without the pressable marker, plus the composite-item roles) and calling innermostInteractive once here.
main's truncation tooltip now mounts on the first hover, tap or focus. The Text stays a tab stop, so keyboard focus mounts and opens it; the focus trigger passes through TruncationTooltip. A Text that holds a link or field leaves the stop to it. TextFocusOwnerContext uses the shared layer-scoped context signature. Item keeps main's row contexts inside TextFocusOwnerContext. The Text record combines both sides' rows.
There was a problem hiding this comment.
Changes requested. Making a truncated Text a tab stop closes the keyboard gap that the current component:Text FR4 names, and the tests and a real-browser Tab check confirm it for a standalone Text. Approval also waits on an engineering owner's decision on the FR4 rewrite (the tab stop, its exceptions for Text inside or holding a control, and the changed default tab order), which an engineering owner records by commenting /approve-spec <full head SHA> on this pull request; the author may do so as an engineering owner. The new grid cell and row test passes, and the five points below still stand from the previous review.
- Newly live check:
packages/core/src/Text/TextFocusOwnerContext.tsis a new internal shared module thatClickableCard,ItemandSelectableCardimport and no current record names, so for an owner API decision it needs its usage, why it is needed, and why the existing pressable-container marker or focus-owner attribute is not enough. - The new FR4 clause "or holds such a control ... which then takes the focus and opens the tooltip" (
Text.spec.md128) does not match the code, because a Tab to a link inside a cut Text mounts the tooltip but opens nothing (this pull request's own text-field test asserts the same), so either list that case in the implementation gap or make it open. - Regression: the Current-state bullet (
Text.spec.md75–80) says keyboard users cannot reveal cut text inside "a button", but the currentcomponent:ButtonFR18 already shows a cut label in full on keyboard focus, so drop "a button" or name Button FR18 and TableHeaderCell FR2. CONTROL_SELECTOR(Text.tsx219–241) is a second hand-rolled list of interactive controls besideINTERACTIVE_SELECTORSandinnermostInteractiveinhooks/useClickableContainer.ts, so extend that shared owner with a focus-owner predicate and call it here.- Newly live check: the
focusTriggerswitch and its comment (Text.tsx446–448,TruncationTooltip.tsx182–203) assume the tooltip decides about focus when it attaches, butuseTooltipdecidesautowhen focus arrives and all 60 Text tests pass with the switch forced to'auto', so drop the switch, the new prop, the comment and the two description sentences that describe it. - Non-blocking: the grid test's "In a focusable row" case (
Text.test.tsx477–483) still passes with[role="row"]removed fromCONTROL_SELECTOR, because its Text sits in agridcell; place the Text directly in the row or in arowheadercell to pin that entry.
Claims and files checked
Review mode: incremental; reason: none
- Claim, a cut Text with its tooltip renders tabindex 0 and a caller's tabIndex wins: verified (
Text.tsx363–364, 415; tests). - Claim, it uses the same mechanism as Timestamp's hover card: verified (
Timestamp.tsx497–498). - Claim, the stop is a prop, so it is in the DOM before the tooltip attaches: verified (
Text.tsx415). - Claim, no stop inside a wrapping link, button, menu item, option, grid row or cell: verified (tests, the new grid test included).
- Claim, no stop inside ClickableCard, SelectableCard, CheckboxListItem, RadioListItem or an interactive Item, through a layer-scoped context, and a Dialog opened from a card gets its own stop: verified (tests).
- Claim, hidden content gets no stop until revealed, and then opens its tooltip on focus: verified (test).
- Claim, a focusable region that is not a control still gets a stop: verified (test).
- Claim, the tooltip re-attaches its focus trigger, and the TruncationTooltip pass-through is what lets revealed text open it: false (finding above).
- Claim, a Text that holds a link or field opens its tooltip on that control's focus, as main already tests: false (finding above).
- Claim, the patch classification follows the compatibility clause it cites: right classification, but
spec:AST-017FR53 is the specific clause. - Claim, the writing rubric ran over the Text record: verified, though the description names the record's old path.
- Claim, no element inside a button or link in the Button truncation story gains a stop: verified (the label is a plain span).
- Claim, real Chrome shows no focus on main and a focused text with its tooltip with this change: verified in Chromium.
- Claim, tsc, lint and the knowledge check are clean: verified at this head.
- Claim, the named suites pass (1,992 tests): the Text, Item, ClickableCard, SelectableCard, CheckboxList, RadioList, Tooltip, Heading and Button suites pass (1,204 tests); Table was not run.
- Claim, the double-read fix is a separate prerequisite: verified that it is not on main.
- Claim, overlap with two other pull requests: not checked (not material to the verdict).
- Changeset, old default, new default, the in-control exception and both opt-outs: verified (tests and code).
- File
.changeset/text-truncation-tab-stop.md: clear. - File
docs/specs/components/Text/Text.spec.md: FR4 clause and Current-state findings, plus the owner decision. - File
packages/core/src/ClickableCard/ClickableCard.tsx: imports the new module (finding above), otherwise clear. - File
packages/core/src/Item/Item.tsx: imports the new module, otherwise clear. - File
packages/core/src/SelectableCard/SelectableCard.tsx: imports the new module, otherwise clear. - File
packages/core/src/Text/Text.doc.mjs: clear. - File
packages/core/src/Text/Text.test.tsx: the grid row case does not pin its entry (non-blocking), otherwise clear. - File
packages/core/src/Text/Text.tsx: control-list and focusTrigger findings, plus a long comment and a JSDoc to trim. - File
packages/core/src/Text/TextFocusOwnerContext.ts: new-module finding. - File
packages/core/src/Text/TruncationTooltip.tsx: focusTrigger finding.
| * layer opened from such a component starts again at false, so its content | ||
| * gets its own tab stops. | ||
| */ | ||
| export const TextFocusOwnerContext = createLayerScopedContext( |
There was a problem hiding this comment.
This is a new internal module that ClickableCard, Item and SelectableCard import, and no current record names it (architecture:knowledge-contracts DEC-22). For an owner API decision it needs its usage, why it is needed, and why the existing pressable-container marker in hooks/useClickableContainer.ts or the private focus-owner attribute is not enough.
| | FR1 | Text renders one element chosen by `as` (default `span`) carrying the `text` target, which reflects `type`, `size`, and the resolved `color`. | Current source and tests | | ||
| | FR2 | A built-in `type` applies its size, line height, and default weight; a theme-added type applies the body baseline. `size` overrides the type's size while keeping its other properties; `weight` overrides the type's default weight. The resolved color is `color`, else the type's default; a theme-added color applies the primary baseline. | Current source and tests | | ||
| | FR3 | `hasCapsize` renders `block` and trims to cap height; otherwise `maxLines` above 1 renders the line-clamp box, `maxLines={1}` renders `block`, and otherwise `display` (default `inline`) applies. `justify` uses logical values; `start`, the default, sets no alignment, so the element follows its container's. `textWrap`, `hasStrikethrough`, and `hasTabularNumbers` apply their text treatments. Without truncation, a token longer than its line wraps, so in ordinary flow the text does not force horizontal scrolling at 320 CSS px (`spec:AST-020` FR1, WCAG 2.2 1.4.10 Reflow). The element's `overflow-wrap` is `break-word`, which keeps min-content, so tables and auto-sized columns lay out ordinary words unchanged; inside a Core container that wraps its content with `anywhere` (CommandPaletteEmpty, Toast, FieldStatus, Banner), it is `anywhere`, as the container's own text is. A flex child needs `min-width: 0` from its container, and a caller's own container that sets `overflow-wrap: anywhere` does not reach the element's text. | Current source and tests | | ||
| | FR4 | `maxLines={1}` clips one line with an ellipsis; a larger value clamps to that many lines unless `hasCapsize` is set, whose `block` display removes the clamp. With truncation, `wordBreak` defaults to `break-all` for one line and `break-word` otherwise. When the text is measured as truncated and `hasTruncateTooltip` is not `false`, a lazily loaded Tooltip anchored to the element shows the full text at the given placement (default `above`), and Text adds no native `title`. `hasTruncateTooltip={false}` takes no measurement. A truncation tooltip can be opened from the keyboard (WCAG 2.2 2.1.1). A truncated Text with its tooltip is a tab stop unless it sits inside a control that takes focus or acts as one item, such as a link, a button, a menu item, an option, or a grid row or cell, or holds such a control, such as a link or a field, which then takes the focus and opens the tooltip. Implementation gap: inside such a control the tooltip opens on hover and touch only (Current-state impact). Truncation re-measures when the content changes without a resize. | Current source and tests | |
There was a problem hiding this comment.
"or holds such a control, such as a link or a field, which then takes the focus and opens the tooltip" does not match the code: a Tab to a link inside a cut Text mounts the tooltip but opens nothing, because Tooltip's auto rule ignores focus on a descendant of an unfocusable trigger (utils/triggerFocus.ts 52–63), and Text.test.tsx 1139 asserts the same for a field. Either list this case in the implementation gap and the Current-state impact, or make that focus open the tooltip and test it.
| functionality to be keyboard operable. The full text stays in the DOM for | ||
| assistive technology. | ||
| - **Truncation tooltip not reachable by keyboard inside a control (FR4).** A | ||
| truncated Text inside a control that takes focus (a link, a button, a menu |
There was a problem hiding this comment.
"a button" contradicts the current component:Button FR18: a Button already shows its cut label in full on keyboard focus, a cut Text label included. Dropping "a button", or saying that Button (FR18) and TableHeaderCell (FR2) already show their cut text on keyboard focus, keeps the bullet true.
| // The tooltip decides once, when it attaches, whether to listen | ||
| // for focus; a stop added later (revealed content) re-attaches it. | ||
| focusTrigger={isTabStop && callerTabIndex == null ? 'always' : 'auto'} |
There was a problem hiding this comment.
useTooltip adds its focus listeners on every attach and decides auto when focus arrives (useTooltip.tsx 757–767, utils/triggerFocus.ts 52–63), and focus on the trigger itself always counts, so this switch changes nothing: all 60 Text.test.tsx cases, the reveal test included, pass with it forced to 'auto'. Suggest dropping it, the new TruncationTooltip prop and this comment, and the two description sentences that describe a re-attach.
| <div role="row" tabIndex={0}> | ||
| <div role="gridcell"> | ||
| <Text type="body" maxLines={1}> | ||
| In a focusable row, wider than the space it has |
There was a problem hiding this comment.
Non-blocking: this Text sits in a gridcell, which CONTROL_SELECTOR matches by itself, so the case still passes with [role="row"] removed from the selector. Putting the Text directly in the focusable row, or in a role="rowheader" cell, makes the row entry the thing under test.
Depends on the truncation-tooltip double-read fix (Text and Heading drop the tooltip's
aria-describedby, since the full text is already in the element). Until that lands, a focused truncated Text has the same text as its name and its description, so a screen reader reads it twice. This PR merges after that fix.Part of #8938 (the Text part). Table, Table row status, Thumbnail and ListItem have their own focus models and follow as separate pull requests.
User impact
When a
TextwithmaxLinesis cut short, its full text sits in a tooltip. That tooltip opened on mouse hover and touch only, because the text never took focus: a sighted keyboard user could not read what was cut. Now a truncated Text is a tab stop, so Tab reaches it and the full-text tooltip opens.Real Chrome 156, built Storybook,
Text › Single line truncation, pressing Tab once from the top of the page:A Text inside a control that already takes focus (a link, a button, a menu item, an option, a grid row or cell, a clickable card) does not become a second, unnamed tab stop inside it, and neither does a Text that holds such a control (a link or a field inside the clamped text), whose own focus opens the tooltip. A focusable region that isn't a control (AppShell's main landmark, a Drawer body, a chat log, a scrollable table viewport) doesn't count, so a Text inside one is still a tab stop. In the
Button › Truncationstory, no element inside a button or link gains a tab stop on either build.Cause
component:TextFR4 (current): "A truncation tooltip can be opened from the keyboard (WCAG 2.2 2.1.1)." The record listed the gap: the tooltip anchors to an element that is not focusable, so Tooltip attaches no focus trigger.Change
Text.tsx: while Text is measured as truncated with its tooltip on, it renderstabIndex={0}, which gives the existing Tooltip its focus trigger. That's the same mechanism Timestamp uses for its hover card. The stop is a prop, so it's in the DOM before the tooltip attaches its focus listeners, and a caller's owntabIndexstill wins. A Text adds no stop inside a control: one that wraps it in the DOM (a link, a button, a menu item, an option, a grid row or cell), found from its ancestors when the element attaches; or a component whose own control sits beside its content and takes focus for all of it: a ClickableCard or SelectableCard (their hidden link, button or checkbox), or an interactive Item (its row, or the input a CheckboxListItem or RadioListItem delegates to). Those say so through a small internal context (TextFocusOwnerContext), which is layer-scoped: a Dialog or Popover opened from them gives its own truncated Text a tab stop. Text hidden from assistive technology (aria-hidden="true",inert) adds no stop either, and gets one when that attribute is removed (a closed Overlay or drawer opening); the tooltip then re-attaches its focus trigger (focusTrigger="always"while Text is the stop), so it opens on that focus.mainthe truncation Tooltip mounts on the first hover, tap or focus (TruncationTooltip). The tab stop is what lets a keyboard focus reach that mount.TruncationTooltippasses Text's focus trigger through to Tooltip, so a stop added later (revealed content) still opens it.mainalready tests.TextFocusOwnerContextuses the shared layer-scoped context signature.Text.spec.md: FR4 states the tab stop and its exceptions for Text inside a control and Text that holds one. The implementation gap and the Current-state bullet narrow to that nested case, where focusing the control does not yet open the text's tooltip. The FR4 verification row names the new tests.Text.spec.md's compatibility rows say the released default changes (a truncated Text is a tab stop) and thattabIndex={-1}keeps one Text out of the tab order.[fix]changeset names the old default (no focus), the new default (tabindex="0"while truncated) and how to restore the old one (tabIndex={-1}, orhasTruncateTooltip={false}). It's[fix]rather than[breaking]underspec:AST-017DEC-17 because it restores the keyboard access the current FR4 contract already requires; no supported caller contract depended on cut-off text being unfocusable.Tests
Text.test.tsx:tabindex="0"(fails on main);menuitem, a ClickableCard, a SelectableCard, a CheckboxListItem or a RadioListItem gets none; a standalone sibling, one inside a focusablemainregion, and one inside a container an Overlay marks as pressable all do;aria-hiddenorinertgets none, and gets one once both are removed;tabIndexpassed after the text is truncated wins.Writing rubric results
Run over
packages/core/src/Text/Text.spec.md, the only record this PR touches:Owner and land path
Overlap checked: #12403 shares
Text.doc.mjsand merges cleanly with this head; #12285 sharesText.spec.mdand already conflicts withmain.