Repository navigation
Conversation
A thread's hidden toggle shows keyboard focus through a focus ring on the thread's surface. On a selected or host-highlighted thread, the forced-colors selection outline came after the ring in the style list and unset its outline outside forced colors, so a keyboard user on the thread they work in saw no focus. The ring now comes last. Forced colors keep the selection outline on an unfocused thread. Cherry-picked from #13736 (by @ernestt). Co-authored-by: Ernest Tien <ernesttien@meta.com>
|
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 |
|---|---|---|---|
| lab/CommentComposer | 192.3 kB (0) · 1.9 kB CSS (0) | — | — · — · — |
| lab/Comments | 392.3 kB (0) · 2.5 kB CSS (0) | — | — · ✓ · — |
| lab/CommentThread | 385.4 kB (0) · 2.4 kB CSS (0) | — | — · — · — |
Package size: no published package changed; no new dependencies.
Not run on this PR: add ci:run-visual for Visual, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
|
/approve-spec adfdc1f |
There was a problem hiding this comment.
Changes requested for one sentence in the description; the code change itself looks right.
- The Testing section says this branch is the validated work rebased onto an earlier
maincommit, but its only parent is themaincommit it was opened on, 255 commits later (including #14106, which editsCommentActions.tsxandComments.test.tsx), so please say which base the reported Vitest and Chromium results came from, or re-run them on this base.
From reading the code, moving surfaceFocused after selectedForcedColors restores the ring on selected and highlighted threads for both thread surfaces, and the new test pins it for the Card surface. CI has not run on this draft head yet.
Claims and files checked
Review mode: same-head; reason: none
- Claim: a selected or highlighted thread now shows its focus ring. Verified (
CommentRow.tsx:242-246; the Card and Section surfaces apply the list last,:256,:276;CommentThread.test.tsx:215-250holds both cases for the Card surface). - Claim: the selection style came after the ring, and outside forced colors its outline removed the ring. Verified (the base style order; the style's
nulloutline defaults atCommentRow.tsx:162-176). - Claim: unselected threads already showed the ring. Verified (the base style list).
- Claim: forced colors keep the selection outline on an unfocused thread and draw the ring on a focused one. Verified from the style list; the rendering is reported.
- Claim: the Comments docs promise the ring on the whole surface while the toggle has focus. Verified (
Comments.doc.mjs:143). - Claim: the interaction-modality record has keyboard focus use the shared focus-visible treatment. Verified as a paraphrase of its system model.
- Claim: an audit rubric item lists this defect, confirmed on
mainin Chromium. Reported. - Claim: only the style order and one comment change in the component. Verified (
CommentRow.tsx+3/-1; the only other file is the test). - Claim: before and after Chromium results and screenshots in light, dark and forced colors. Reported.
- Claim: the regression test checks the ring classes for a selected and a highlighted thread. Verified (
CommentThread.test.tsx:215-250); that it fails without the fix is reported and traced against the base. - Claim: Vitest, the review checklist, Prettier and ESLint are clean. Reported; CI has not run on this head.
- Claim: Chromium runs on static Storybook builds of
mainand this branch. Reported. - Claim: validated on an earlier
maincommit. Reported. - Claim: this branch is that work rebased onto an earlier
maincommit. False: its only parent is the base it was opened on, 255 commits later. - Claim: cherry-picked from #13736 by its author with co-author credit, as the same change. Verified (commit trailer; every patch line of #13736 is in this diff).
- Claim: this pull request carries the fix onto current
main. Verified as of opening: the head sits on themaincommit it was opened on;mainhas since gained one commit that touches no Comments file. - Claim: #14155 replaces #13737. Verified (the same nine files with the same line counts).
- Claim: the other listed pull requests are separate changes. Verified (none edits the thread surface's style list).
- Claim: the scope checklist (one defect, no tag-alongs, no hidden API or visual direction, no internal context). Verified.
- File
packages/lab/src/Comments/CommentRow.tsx: clear. - File
packages/lab/src/Comments/CommentThread.test.tsx: clear.
|
🤖 (Posted by Cindy's agent.) Thanks. The Testing section no longer says the branch was rebased. It now names what was checked on the original pull request, and the checks rerun at this head on current |
There was a problem hiding this comment.
Approved. Moving the focus-ring style after the forced-colors selection style restores the ring on selected and highlighted threads, CI's unit tests at this head pass both new cases, and a Chromium check here reproduced the missing ring on main and the 2px ring with this change.
Claims and files checked
Review mode: same-head; reason: none
- Rules changed since the last review: none.
- Title: a selected or highlighted thread shows its focus ring. Verified (
CommentRow.tsx:242-246; CI'stest-uipasses both cases inCommentThread.test.tsx:215-250; reproduced locally on the OpenThread story:outline-style: noneon the base, a 2px solid ring at offset 3px here, in light and dark). - Cherry-picked from #13736, with co-author credit for its author. Verified (the commit's Co-authored-by trailer; #13736's diff is byte-identical to this one).
- This pull request carries the fix onto current
main. Verified as of opening: the head's only parent was themaintip then;mainhas since gained 12 commits that touch no Comments file, Card, Section or focus token, and the head still merges cleanly. - On the base, keyboard focus on a selected or highlighted thread showed no ring, while unselected threads showed it. Verified (base style order; reproduced locally for the selected state).
- The hidden toggle draws its ring on the thread surface. Verified (
CommentRow.tsx:226-246). - The selection style came after the ring and, outside forced colors, left the outline at none. Verified (the
nulldefaults atCommentRow.tsx:162-176; the base order; the local probe). - Enter or Space on the toggle opens and closes the thread. Verified (a native button,
CommentRow.tsx:228-236; the existing keyboard test atCommentThread.test.tsx:189-213). - The ring now comes last; forced colors keep the selection outline on an unfocused thread and draw the ring on a focused one. Verified (the style list; reproduced locally in forced colors: the unfocused frame is pixel-identical, the focused one shows the ring).
- The Comments docs promise the ring on the whole surface while the toggle has focus. Verified (
Comments.doc.mjs:143). - The interaction-modality record has keyboard focus use the shared focus-visible treatment. Verified as a paraphrase of its system model.
- An audit rubric item lists this defect, confirmed on
mainin Chromium. Reported. - Only the style order and one comment change in the component. Verified (
CommentRow.tsx+3/-1; the only other file is the test). - Before and after Chromium results and screenshots in light, dark and forced colors. Reported, and consistent with the local run for the selected state.
- The regression test checks the ring classes for a selected and a highlighted thread and fails without the fix. Verified that it checks both and passes in CI's
test-uiat this head; the red run is reported and traced against the base. - The scope checklist: one defect, no tag-alongs, no hidden API or visual direction, no internal context. Verified.
- On #13736, the Comments tests, pre-review checks, Prettier, ESLint and Chromium runs were clean. Reported.
- At this head, install, build, typecheck, Prettier, ESLint and the changeset check pass, and the Comments tests pass 96 of 96. Reported; CI at this head passes its typecheck, lint and build jobs and runs all 96 Comments cases green.
- In Chromium on the Comments Panel story,
mainshows no ring and this head a 2px solid ring at offset 3px on selected and highlighted threads, the ring shows in forced colors when focused, and a plain thread is unchanged. Reported; the selected and forced-colors states match the local run, and the committed stories render no highlighted thread, so that state needed a fixture the description does not name. - The listed pull requests are separate changes, #14155 replaces #13737, and the other five are the original author's own Comments pull requests. Verified (#14155 and #13737 change the same nine files; each of the others has its own title and files).
- File
packages/lab/src/Comments/CommentRow.tsx: clear. - File
packages/lab/src/Comments/CommentThread.test.tsx: clear.
There was a problem hiding this comment.
Changes requested. Moving the focus-ring style after the forced-colors selection style restores the ring on focused selected and highlighted threads (the new tests pass here and in CI, and a Chromium check here shows the ring), but one description claim does not hold.
- Miss: after a thread's toggle is removed while it has focus (the host sets
isSubmittingand then clears it), a selected or highlighted thread keeps the focus ring with focus on the page body and, in forced colors, shows it in place of the selection outline, so "Forced colors still draw the selection outline on an unfocused selected thread" is false untilisFocusedis cleared when the toggle detaches (for example in its ref callback) and a test covers that round trip.
The inline comment on CommentRow.tsx has the reproduction and a suggested fix.
Claims and files checked
Review mode: same-head; reason: none
- Rules changed since the last review (3): "Claim bounding in one round": finding (the forced-colors sentence, bounded in Problem and solution fit and in Evidence). "Read the bound a claim already carries": checked: the sentence's own bound, an unfocused selected thread, excludes nothing, so only the removed-toggle case is listed. "For a claim about focus, events or DOM placement": a toggle removed while focused falsifies it; a click that leaves the toggle unfocused, a non-HTML control, an iframe or Picture-in-Picture window, a shadow root, a disabled or hidden toggle, a covering surface and a caller-supplied focus target do not apply, and Comments and CommentThread on both surfaces share the same code.
- Title (live): "fix(Comments): a selected or highlighted thread shows its focus ring". Verified (
CommentRow.tsx:242-246; the two new cases inCommentThread.test.tsx:215-250pass here and in CI'stest-ui; in Chromium here a focused selected thread goes from no outline to a 2px solid ring at offset 3px). - Cherry-picked from #13736, with co-author credit for its author. Verified (the commit's Co-authored-by trailer; every added line of #13736 is in this diff).
- This pull request carries the fix onto current
main. Verified (the head's only parent is the base;mainhas since gained commits that touch no Comments file, Card, Section or focus token, and the head still merges cleanly). - On the base, keyboard focus on a selected or highlighted thread showed no ring while unselected threads showed it. Verified (base style order; reproduced here on the base for both states).
- The hidden toggle draws its ring on the thread surface. Verified (
CommentRow.tsx:226-246). - The selection style came after the ring and, outside forced colors, set the outline to none. Verified (the
nulldefaults atCommentRow.tsx:162-176; the base probe here). - Focus visibility fails on the open thread, and Enter or Space on the toggle opens and closes it. Verified (a native button at
CommentRow.tsx:228-236; the keyboard test atCommentThread.test.tsx:189-213passes here). - The ring now comes last. Verified (
CommentRow.tsx:242-246). - Forced colors still draw the selection outline on an unfocused selected thread, and the ring on a focused one. False for an unfocused selected or highlighted thread whose toggle was removed while focused (see the finding); the focused half is verified.
- The Comments docs promise the ring on the whole surface while the toggle has focus. Verified (
Comments.doc.mjs:143). - Keyboard focus uses the shared focus-visible treatment under the interaction-modality record. Verified as a paraphrase of the record's system model; the record applies to Core, so it is context for this Lab change.
- An audit rubric item lists this defect, confirmed on
mainin Chromium. Reported. - Only the style order and one comment change in the component. Verified (
CommentRow.tsx+3/-1; the only other file is the test). - Before and after Chromium results in light and dark: no outline on the base, a 2px solid ring on the head. Reported; consistent with the runs here.
- The unchanged forced-colors path for a selected, unfocused thread. Reported for a thread never focused; the same bound as the forced-colors claim applies.
- The regression test checks the ring classes for a selected and a highlighted thread and fails without the fix. Verified (it checks both and passes here; the same class check finds no ring on the base here).
- Chrome 158 stills from a public Actions run at this head and at its merge base with
main, with a throwaway story:3px noneonmain,2px solidhere. Reported; the merge base is correct and the values match the runs here. - The scope checklist: one defect, no tag-alongs, no hidden API or visual direction, no internal context. Verified (no API, default or interaction-model change and no internal context; the stray ring is the finding above, not a hidden direction).
- On #13736, the Comments tests, pre-review checks, Prettier, ESLint and Chromium runs were clean. Reported.
- At this head, install, build, typecheck, Prettier, ESLint and the changeset check pass, and the Comments tests pass 96 of 96. Reported; CI at this head passes its typecheck, lint, build and
test-uijobs. - In Chromium 155,
mainshows no ring and this head a 2px solid ring at offset 3px on selected and highlighted threads, the ring shows in forced colors when focused, and a plain thread is unchanged. Reported; consistent with the runs here. - The listed pull requests are separate changes, #14155 replaces #13737, and the others are the original author's own Comments pull requests. Verified (#14155 and #13737 change the same nine files; none of the others edits the thread surface's style list).
- File
packages/lab/src/Comments/CommentRow.tsx: finding (line 245 with the focus state at lines 215 and 234-235). - File
packages/lab/src/Comments/CommentThread.test.tsx: clear.
| isSelectable && styles.surface, | ||
| isSelectable && isFocused && styles.surfaceFocused, | ||
| isFilled && styles.selectedForcedColors, | ||
| isSelectable && isFocused && styles.surfaceFocused, |
There was a problem hiding this comment.
Miss: isFocused only changes in the toggle's onFocus and onBlur (lines 234-235), and React runs no onBlur when it removes the focused toggle, which happens while the thread cannot be selected (for example while the host's isSubmitting is true). With this style now last, a selected or highlighted thread keeps the ring after the toggle comes back, though focus is on the page body; in forced colors the ring also replaces the selection outline. Reproduced here in Chromium 158: Tab to a selected thread's toggle, set isSubmitting to true and then false, and the surface still computes a 2px solid outline at offset 3px with document.activeElement on the body (the base keeps no outline there, and the inset Highlight outline in forced colors).
Clearing the state when the toggle detaches fixes it, and a test for that round trip would pin it:
const setControl = useCallback((node: HTMLButtonElement | null) => {
controlRef.current = node;
// React runs no onBlur for a focused node it removes.
if (node == null) {
setIsFocused(false);
}
}, []);
Cherry-picked from #13736 by @ernestt, who wrote this fix; the commit credits @ernestt with a
Co-authored-byline. This team pull request carries it onto currentmain.User impact
A keyboard user who tabs to a Comments thread that is selected (open) or highlighted by the host sees no focus indicator. That is the thread they are working in, so they lose track of where focus is. Unselected threads show the ring.
Problem and solution fit
The ring now comes last in the style list. Forced colors still draw the selection outline on an unfocused selected thread, and the ring on a focused one.
Expected behavior and authority
architecture:interaction-modality: keyboard focus uses the shared focus-visible treatment.mainin Chromium before this change:outline-style: noneon a selected, focused thread.Smallest restoration
The style order in
CommentRowchanges sosurfaceFocusedfollowsselectedForcedColors. One comment says why the order matters. Nothing else changes.Evidence
:focus-visibleapplies. The surface's computed outline isnone, in light and dark.solid 2pxwith the focus color, in light and dark.CommentThread.test.tsxchecks the focus-ring classes on[data-thread-surface]for a selected and a highlighted thread. It fails without the fix.Branded Chrome stills at this head
Google Chrome 158.0.8127.37 on macOS, in a one-off public Actions run. It built Storybook at this head (
adfdc1f6) and at its merge base withmain(4700add1), each with the same throwaway story: a margin thread with one reply, rendered selected or highlighted by its host. The run pressed Tab until the thread's toggle took keyboard focus. It used DPR 2 and reduced motion. The recorded outline on the focused thread is3px noneon main and2px solidhere.4700add1)Scope
Components: Comments, CommentThread
Testing
vitest run packages/lab/src/Commentspassed, and the new cases fail without the fix.pnpm review:pre,prettierandeslintwere clean, and real Chromium ran on static Storybook builds (light, dark, forced colors).main), rerun on Linux:tsc(core, lab),prettier,eslintandcheck:changesetsall pass;mainagainst this head, on the Lab/Comments panel story:main(3px none); a2px solidring at offset 3px here;mainkeeps the selection outline, and here the focus ring shows;Overlap checked: #14155, #13741, #13740, #13738, #13737, #13736, #13739, #13735 (separate: #13736 is the original by @ernestt, which this team pull request replaces with the same commit on current main; #14155 replaces #13737; #13738, #13739, #13740, #13741 and #13735 are ernestt's other Comments pull requests, each its own change; whichever lands second merges main)