Repository navigation
fix(Popover): focus entry takes the first content control in document order - #11177
Conversation
… order preferTabStops, which both Popover focus entries use, sorts its candidates into document order before it puts tab stops first. A browser's querySelectorAll already returns document order; jsdom can return a selector list's matches grouped by selector, so a field before its buttons lost initial focus to the first button in tests. Popover FR2 names document order.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| MoreMenu | 101.4 kB (+62 B) · 17.6 kB CSS (0) | — | — · — · — |
| DropdownMenu | 101.1 kB (+60 B) · 17.6 kB CSS (0) | — | — · — · — |
| lab/CommentThread | 350.6 kB (+57 B) · 2.4 kB CSS (0) | — | — · — · — |
58 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| ComplexSelector | 75.4 kB (+56 B) · 11.9 kB CSS (0) | — | — · — · — |
| lab/TourStep | 101.4 kB (+47 B) · 590 B CSS (0) | — | — · — · — |
| lab/ChatEmojiPicker | 110.3 kB (+38 B) · 773 B CSS (0) | — | — · — · — |
| lab/TransferListSelector | 114.0 kB (+38 B) · 1.4 kB CSS (0) | — | — · — · — |
| MultiSelector | 99.1 kB (+34 B) · 16.9 kB CSS (0) | — | — · — · — |
| lab/ChatReactionBar | 111.5 kB (+34 B) · 1.1 kB CSS (0) | — | — · — · — |
| DateRangeInput | 97.1 kB (+33 B) · 12.5 kB CSS (0) | — | — · — · — |
| ChatComposerInput | 80.0 kB (+31 B) · 11.3 kB CSS (0) | — | — · — · — |
| ChatComposerTokenElement | 80.0 kB (+31 B) · 11.3 kB CSS (0) | — | — · — · — |
| Popover · Storybook | 95.1 kB (+29 B) · 14.2 kB CSS (0) | 1,556 (0) | ✓ · ✓ · ✓ |
| Selector | 104.4 kB (+29 B) · 17.4 kB CSS (0) | — | — · — · — |
| TopNavMegaMenu | 74.1 kB (+29 B) · 11.9 kB CSS (0) | — | — · — · — |
| Pagination | 114.5 kB (+28 B) · 17.8 kB CSS (0) | — | — · — · — |
| TopNavMenu | 78.6 kB (+28 B) · 11.3 kB CSS (0) | — | — · — · — |
| TabMenu | 75.9 kB (+27 B) · 11.2 kB CSS (0) | — | — · — · — |
| ChatComposer | 82.3 kB (+26 B) · 12.1 kB CSS (0) | — | — · — · — |
| DateInput | 191.0 kB (+26 B) · 17.1 kB CSS (0) | — | — · — · — |
| BaseTypeahead | 76.0 kB (+25 B) · 11.0 kB CSS (0) | — | — · — · — |
| BreadcrumbItem | 88.7 kB (+25 B) · 12.1 kB CSS (0) | — | — · — · — |
| SideNavHeading | 79.6 kB (+25 B) · 11.3 kB CSS (0) | — | — · — · — |
| lab/Comments | 357.5 kB (+24 B) · 2.5 kB CSS (0) | — | — · — · — |
| SideNavItem | 74.8 kB (+23 B) · 11.2 kB CSS (0) | — | — · — · — |
| TopNavHeading | 79.2 kB (+23 B) · 11.3 kB CSS (0) | — | — · — · — |
| Typeahead | 84.8 kB (+23 B) · 12.5 kB CSS (0) | — | — · — · — |
| lab/CommentComposer | 155.8 kB (+23 B) · 1.9 kB CSS (0) | — | — · — · — |
| DateTimeInput | 213.2 kB (+22 B) · 18.7 kB CSS (0) | — | — · — · — |
| PowerSearch | 295.6 kB (+22 B) · 24.5 kB CSS (0) | — | — · — · — |
| Tokenizer | 100.7 kB (+21 B) · 19.1 kB CSS (0) | — | — · — · — |
| richtext/RichTextEditorToolbar | 283.4 kB (+21 B) · 454 B CSS (0) | — | — · — · — |
| lab/LineClamp | 15.7 kB (+5 B) · 168 B CSS (0) | — | — · — · — |
| TableHeaderCell | 112.9 kB (+4 B) · 17.7 kB CSS (0) | — | — · — · — |
| ContextMenu | 112.1 kB (+3 B) · 17.5 kB CSS (0) | — | — · — · — |
| TableCell | 113.4 kB (+3 B) · 17.9 kB CSS (0) | — | — · — · — |
| CodeBlock | 78.3 kB (+2 B) · 11.3 kB CSS (0) | — | — · — · — |
| BottomSheet | 69.2 kB (+1 B) · 7.7 kB CSS (0) | — | — · — · — |
| Collapsible | 28.5 kB (+1 B) · 4.5 kB CSS (0) | — | — · — · — |
| Dialog | 24.9 kB (+1 B) · 6.9 kB CSS (0) | — | — · — · — |
| Markdown | 192.3 kB (+1 B) · 20.8 kB CSS (0) | — | — · — · — |
| ScrollableArea | 11.3 kB (+1 B) · 4.2 kB CSS (0) | — | — · — · — |
| lab/DiffViewer | 90.3 kB (+1 B) · 2.1 kB CSS (0) | — | — · — · — |
| AlertDialog | 108.9 kB (0) · 14.6 kB CSS (0) | — | — · — · — |
| ChatLayout | 85.9 kB (0) · 10.6 kB CSS (0) | — | — · — · — |
| DropdownMenuSubMenu | 72.1 kB (0) · 9.7 kB CSS (0) | — | — · — · — |
| LayoutPanel | 21.9 kB (0) · 4.9 kB CSS (0) | — | — · — · — |
| Lightbox | 125.7 kB (0) · 10.6 kB CSS (0) | — | — · — · — |
| MobileNav | 73.7 kB (0) · 10.6 kB CSS (0) | — | — · — · — |
| SideNav | 118.0 kB (0) · 11.4 kB CSS (0) | — | — · — · — |
| Table | 129.3 kB (0) · 18.4 kB CSS (0) | — | — · — · — |
| TimeInput | 165.9 kB (0) · 16.1 kB CSS (0) | — | — · — · — |
| TreeList | 45.7 kB (0) · 5.6 kB CSS (0) | — | — · — · — |
| lab/ChatVirtualizer | 55.6 kB (0) · 144 B CSS (0) | — | — · — · — |
| lab/EmojiPicker | 90.0 kB (0) · 751 B CSS (0) | — | — · — · — |
| AppShell | 94.9 kB (−1 B) · 13.5 kB CSS (0) | — | — · — · — |
| CommandPalette | 74.9 kB (−1 B) · 12.7 kB CSS (0) | — | — · — · — |
| TopNav | 75.4 kB (−1 B) · 11.0 kB CSS (0) | — | — · — · — |
| lab/NavigationScreen | 83.5 kB (−1 B) · 1.5 kB CSS (0) | — | — · — · — |
| lab/NavigationStack | 83.5 kB (−1 B) · 1.5 kB CSS (0) | — | — · — · — |
| Drawer | 52.5 kB (−2 B) · 8.3 kB CSS (0) | — | — · — · — |
Package size: @astryxdesign/core 7.32 MB packed (+193 B); no new dependencies.
Touched components checked; add ci:run-visual or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
|
/approve-spec 2bc1578 |
There was a problem hiding this comment.
Changes requested: two fixes before this can merge.
The code fix is sound: sorting preferTabStops' candidates gives the first content control initial focus in jsdom, as browsers already do, and the new test fails before the change and passes after it.
- The new FR2 text, "first genuine caller content in document order" (
docs/specs/components/Popover/Popover.spec.md:196), contradicts the tab-stop preference Popover ships and tests (Popover.test.tsx:1126opens a toolbar on Italic,tabindex="0", over the earlier Bold,tabindex="-1"), so reword it to "first genuine caller content in document order, tab stops before members that holdtabindex="-1", then labeled dialog-surface fallback" or drop the record edit, since the code already conforms to the current FR2. - Found by CI: the required
lintcheck fails because no Changeset names@astryxdesign/corefor the change topackages/core/src/hooks/focusableSelector.ts, so add one withpnpm changeset:new --packages @astryxdesign/core --category fixthat says initial focus changes only wherequerySelectorAlldoes not return document order, as in jsdom, and that browsers focus the same control as before.
A new commit that still changes the record needs a fresh /approve-spec <full head SHA> from an engineering owner on that head. Non-blocking: the new comment in focusableSelector.ts would read more plainly as "A browser's querySelectorAll returns document order. jsdom can group a selector list's matches by selector. Sort them here."
FR2 names document order with tab stops before members that hold tabindex="-1", as Popover ships and tests. The changeset says initial focus changes only where querySelectorAll does not return document order, as in jsdom.
|
/approve-spec baec8f4 |
There was a problem hiding this comment.
Approved. CI passes on this head.
Sorting preferTabStops' candidates into document order gives Popover's focus entry the first content control under jsdom, as browsers already do. The new test fails before the change and passes after it, the roving toolbar still opens on its tab stop, and Chromium focuses the same control before and after. The FR2 wording now names the tab-stop preference and carries an engineering owner's approval for this head.
No changes requested.
Brings in #11177 (Popover focus entry in document order). Co-authored-by: ernestt <[email protected]>
With Popover's focus entry taking the first content control in document order (#11177), the form no longer turns hasAutoFocus off and focuses its field from an Effect. The record drops FR4's slot-system status line and says AST-061 owns the toolbar's props; the link anchor styles no longer split the Divider comment from its styles. Co-authored-by: ernestt <[email protected]>
…nk dialog with an anchored popover (#8717) * feat(richtext): replace the toolbar link dialog with an anchored popover RichTextEditorToolbar's Link button, and Cmd/Ctrl+K in the editor, open a non-modal Popover anchored to the button instead of a modal Dialog. It holds one plain-text URL field (URL keyboard, URL autocomplete, no spellcheck, a placeholder) and Apply, Remove (when the selection is in a link), and Cancel icon buttons with tooltips. Enter applies; Escape or Cancel closes it and returns focus and the selection to the editor; a URL that cannot be linked shows the field's error status and keeps focus in the field. The URL rules, hasNewTabLinks, promptForUrl, and the Cmd/Ctrl+K shortcut are unchanged. RICHTEXT_ICON_KEYS gains applyLink, removeLink, and cancel with bundled fallbacks, and the catalog gains the field's placeholder. Co-authored-by: Emily Horsman <[email protected]> * fix(richtext): the link popover uses shared icons, Popover focus and TextInput hints, and opens above the toolbar - Apply and Cancel draw the shared check and close icons, so a theme restyles them through icons; Remove draws fixed artwork. The form adds no richtext:* icon key. - The Popover's own focus handling moves focus to the URL field; the field's URL keyboard and spelling hints use TextInput's props. - Cmd/Ctrl+K brings the Link button into view before the popover opens. - The popover opens above the toolbar and flips below only when there is no room, so it does not cover the editor's first lines. - A RichTextEditorToolbar record holds the link control's contract. * fix(richtext): the link field keeps its own focus, and a missing scrollIntoView does not stop the popover * Merge main into richtext-link-popover Resolves RichTextEditorToolbar.tsx (the link prop's doc keeps the popover text and adds main's #9668 caret insertion) and RichTextEditor.test.tsx (imports from both sides). The popover's apply path is main's single update, which inserts the URL as link text at a collapsed caret. Co-authored-by: ernestt <[email protected]> * docs(richtext): the link popover changeset names what ships; FR6 names the empty field and its placeholder Apply and Cancel use the shared check and close icons and RICHTEXT_ICON_KEYS is unchanged, so the changeset no longer claims new icon keys. It also names the placement: above the toolbar, below only without room. Co-authored-by: ernestt <[email protected]> * test(richtext): link tooltips are read from the layer when they repeat the button's name; the record's compatibility row is present tense Button on main no longer describes itself by a tooltip that repeats its name, so tooltipOf falls back to the tooltip layer's text. Co-authored-by: ernestt <[email protected]> * fix(richtext): the link popover anchors to a wrapper a press never scales Button scales on press, so the open popover moved with a press on the Link button it anchored to (layer-runtime INV22). It now anchors to a wrapper around the button; Popover finds the button inside for its handlers and ARIA. Co-authored-by: ernestt <[email protected]> * Merge main into richtext-link-popover Brings in #11177 (Popover focus entry in document order). Co-authored-by: ernestt <[email protected]> * fix(richtext): the link popover's own focus entry focuses the URL field With Popover's focus entry taking the first content control in document order (#11177), the form no longer turns hasAutoFocus off and focuses its field from an Effect. The record drops FR4's slot-system status line and says AST-061 owns the toolbar's props; the link anchor styles no longer split the Divider comment from its styles. Co-authored-by: ernestt <[email protected]> * docs(storybook): show the link popover above the toolbar, and its flip below WithLinks gets room above the editor, so the link popover opens above the toolbar as it does on a page. WithLinksNoRoomAbove puts the toolbar at the top of the page, where the popover flips below it. Stories only. Co-authored-by: ernestt <[email protected]> * test(richtext): drop the unused afterAll import Co-authored-by: ernestt <[email protected]> * Merge branch 'main' into richtext-link-popover * docs(RichTextEditorToolbar): hasLink and promptForUrl name the link popover Co-authored-by: ernestt <[email protected]> * Merge remote-tracking branch 'refs/remotes/l4/main-new' into lane4/x8717 Co-authored-by: Cindy Zhang <[email protected]> Co-authored-by: cixzhang <[email protected]>
…rs (#11189) * feat(richtext): replace the toolbar link dialog with an anchored popover RichTextEditorToolbar's Link button, and Cmd/Ctrl+K in the editor, open a non-modal Popover anchored to the button instead of a modal Dialog. It holds one plain-text URL field (URL keyboard, URL autocomplete, no spellcheck, a placeholder) and Apply, Remove (when the selection is in a link), and Cancel icon buttons with tooltips. Enter applies; Escape or Cancel closes it and returns focus and the selection to the editor; a URL that cannot be linked shows the field's error status and keeps focus in the field. The URL rules, hasNewTabLinks, promptForUrl, and the Cmd/Ctrl+K shortcut are unchanged. RICHTEXT_ICON_KEYS gains applyLink, removeLink, and cancel with bundled fallbacks, and the catalog gains the field's placeholder. Co-authored-by: Emily Horsman <[email protected]> * fix(richtext): the link popover uses shared icons, Popover focus and TextInput hints, and opens above the toolbar - Apply and Cancel draw the shared check and close icons, so a theme restyles them through icons; Remove draws fixed artwork. The form adds no richtext:* icon key. - The Popover's own focus handling moves focus to the URL field; the field's URL keyboard and spelling hints use TextInput's props. - Cmd/Ctrl+K brings the Link button into view before the popover opens. - The popover opens above the toolbar and flips below only when there is no room, so it does not cover the editor's first lines. - A RichTextEditorToolbar record holds the link control's contract. * fix(richtext): the link field keeps its own focus, and a missing scrollIntoView does not stop the popover * Merge main into richtext-link-popover Resolves RichTextEditorToolbar.tsx (the link prop's doc keeps the popover text and adds main's #9668 caret insertion) and RichTextEditor.test.tsx (imports from both sides). The popover's apply path is main's single update, which inserts the URL as link text at a collapsed caret. Co-authored-by: ernestt <[email protected]> * docs(richtext): the link popover changeset names what ships; FR6 names the empty field and its placeholder Apply and Cancel use the shared check and close icons and RICHTEXT_ICON_KEYS is unchanged, so the changeset no longer claims new icon keys. It also names the placement: above the toolbar, below only without room. Co-authored-by: ernestt <[email protected]> * test(richtext): link tooltips are read from the layer when they repeat the button's name; the record's compatibility row is present tense Button on main no longer describes itself by a tooltip that repeats its name, so tooltipOf falls back to the tooltip layer's text. Co-authored-by: ernestt <[email protected]> * refactor(richtext): share the toolbar's link popover and format helpers Behavior-neutral. The toolbar's link popover state and actions move to useToolbarLink and ToolbarLinkPopover in ToolbarLinkPopover.tsx, with isInsertLink. The URL form moves to linkForm.tsx as LinkForm, and the address rule to linkEditing.ts as toLinkHref. The toolbar exports its inline formats, their labels, the formats a selection carries, the format command, and its glyph resolver for other RichText modules. The package entry exports none of it. Co-authored-by: Ernest Tien <[email protected]> * refactor(richtext): name the system useToolbarLink's Effect syncs with Co-authored-by: Ernest Tien <[email protected]> * fix(richtext): the link popover anchors to a wrapper a press never scales Button scales on press, so the open popover moved with a press on the Link button it anchored to (layer-runtime INV22). It now anchors to a wrapper around the button; Popover finds the button inside for its handlers and ARIA. Co-authored-by: ernestt <[email protected]> * Merge richtext-link-popover (#8717) into richtext-link-extraction Takes #8717's non-scaling wrapper around the toolbar's Link button: ToolbarLinkPopover anchors to that wrapper, and useToolbarLink's option, which scrolls the button into view, is now buttonRef. Co-authored-by: Ernest Tien <[email protected]> * Merge main into richtext-link-popover Brings in #11177 (Popover focus entry in document order). Co-authored-by: ernestt <[email protected]> * fix(richtext): the link popover's own focus entry focuses the URL field With Popover's focus entry taking the first content control in document order (#11177), the form no longer turns hasAutoFocus off and focuses its field from an Effect. The record drops FR4's slot-system status line and says AST-061 owns the toolbar's props; the link anchor styles no longer split the Divider comment from its styles. Co-authored-by: ernestt <[email protected]> * Merge richtext-link-popover (#8717) into richtext-link-extraction Takes #8717's removal of the form's focus Effect and of hasAutoFocus={false}: Popover's focus entry focuses the URL field. In this branch that code lives in linkForm.tsx and ToolbarLinkPopover.tsx. Co-authored-by: Ernest Tien <[email protected]> * Merge main into richtext-link-extraction * docs(RichTextEditorToolbar): the record names the link popover's files; comments tighten
Summary
Popover's focus entry picks the first content control in document order, in every environment.
preferTabStops(hooks/focusableSelector.ts), which both Popover focus entries use (the anchored layer inusePopoverand the sheet inPopover), sorts its candidates into document order before it puts tab stops first. Its own doc already says "each group in document order".querySelectorAllreturns document order, so in a browser this is behavior-neutral. jsdom 27 can return the matches of a selector list grouped by selector instead (forFOCUSABLE_SELECTOR: everybuttonbefore everyinput). So in tests, a Popover whose content is a field followed by buttons focused the first button, not the field. A component test that relies on Popover's focus entry then had to turn it off and focus its own field from an Effect.tabindex="-1"", which is what Popover ships and tests.No public API, default or browser behavior changes. The core changeset says the focused control changes only where
querySelectorAlldoes not return document order, as in jsdom.Tests
Popover.test.tsxcase: "focuses the first content control in document order, a field before its buttons". It fails before the change (jsdom focuses Apply) and passes after.focusableSelector, and every test file that renders a Popover in core, richtext and lab pass (targeted, one worker).Writing rubric results