Repository navigation
fix(ScrollableArea): a focus move inside the area adds no commit - #11135
Conversation
|
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 |
|---|---|---|
| TimeInput | 164.4 kB (+80 B) · 16.1 kB CSS (0) | — |
| lab/EmojiPicker | 88.6 kB (+56 B) · 751 B CSS (0) | — |
| Markdown | 190.5 kB (+41 B) · 20.8 kB CSS (0) | — |
28 more components
| Component | Size | LoC |
|---|---|---|
| ScrollableArea | 11.3 kB (+36 B) · 4.2 kB CSS (0) | — |
| Table | 127.6 kB (+35 B) · 18.4 kB CSS (0) | — |
| lab/Comments | 354.9 kB (+35 B) · 2.5 kB CSS (0) | — |
| lab/ChatVirtualizer | 55.6 kB (+30 B) · 144 B CSS (0) | — |
| lab/CommentComposer | 154.1 kB (+30 B) · 1.9 kB CSS (0) | — |
| lab/NavigationStack | 83.2 kB (+28 B) · 1.5 kB CSS (0) | — |
| lab/NavigationScreen | 83.2 kB (+27 B) · 1.5 kB CSS (0) | — |
| lab/CommentThread | 347.9 kB (+25 B) · 2.4 kB CSS (0) | — |
| BottomSheet | 69.0 kB (+23 B) · 7.7 kB CSS (0) | — |
| DateInput | 189.1 kB (+19 B) · 17.1 kB CSS (0) | — |
| lab/DiffViewer | 88.9 kB (+14 B) · 2.1 kB CSS (0) | — |
| lab/ChatReactionBar | 109.1 kB (+13 B) · 1.1 kB CSS (0) | — |
| PowerSearch | 292.4 kB (+11 B) · 24.2 kB CSS (0) | — |
| lab/ChatEmojiPicker | 107.9 kB (+11 B) · 773 B CSS (0) | — |
| CodeBlock | 76.9 kB (+7 B) · 11.3 kB CSS (0) | — |
| Popover | 92.7 kB (+1 B) · 14.2 kB CSS (0) | — |
| Tokenizer | 94.1 kB (+1 B) · 18.8 kB CSS (0) | — |
| ContextMenu | 110.7 kB (0) · 17.5 kB CSS (0) | — |
| MoreMenu | 99.1 kB (0) · 17.6 kB CSS (0) | — |
| MultiSelector | 96.7 kB (0) · 16.9 kB CSS (0) | — |
| Pagination | 112.2 kB (0) · 17.8 kB CSS (0) | — |
| Selector | 102.1 kB (0) · 17.4 kB CSS (0) | — |
| TableCell | 111.9 kB (0) · 17.9 kB CSS (0) | — |
| TableHeaderCell | 111.5 kB (0) · 17.7 kB CSS (0) | — |
| lab/TourStep | 99.0 kB (0) · 590 B CSS (0) | — |
| richtext/RichTextEditorToolbar | 280.7 kB (−1 B) · 454 B CSS (0) | — |
| DropdownMenu | 98.8 kB (−2 B) · 17.6 kB CSS (0) | — |
| DateTimeInput | 210.7 kB (−6 B) · 18.7 kB CSS (0) | — |
Package size: @astryxdesign/core 7.29 MB packed (+216 B); no new dependencies.
Not run on this PR: add ci:run-visual, ci:run-a11y or ci:run-rtl to run them.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Requesting changes for one wording fix; the code change itself is sound. The new test fails without the guard, and the existing focus cases fail if the guard stops recording the value it set.
.changeset/scrollable-area-focus-move-no-commit.md:5says every ScrollableArea used to render again on this focus hand-off, but a scrolling viewport already cost one commit and only a viewport whose content fits cost two, so please scope the note, for example: "[fix] A ScrollableArea whose content fits, and a component built on useScrollableArea such as BottomSheet, no longer renders again when a commit moves focus between two of its descendants."
Optional: the first sentence of the setIfChanged comment restates its name, and the second sentence alone carries the reason.
6a9ec5c to
ca60fa4
Compare
There was a problem hiding this comment.
Requesting changes for one wording fix. The code change itself is sound: the new test fails without the guard, and 8 existing focus cases fail if the guard stops recording the value it wrote.
- Miss:
.changeset/scrollable-area-focus-move-no-commit.md:5says a fitting ScrollableArea rendered again when a commit moved focus between two of its descendants, but onmainthat hand-off already costs one commit, since only a component whose own commit moves focus (as in the new test), or the first focus move right after the area's own update, rendered again; please reword it, for example: "[fix] A component built on useScrollableArea, such as ScrollableArea or BottomSheet, no longer renders again when focus moves between two descendants of a fitting viewport just after the component's own update."
The earlier automated review suggested this wording. The pull request body's User impact repeats the claim. Optional: the setIfChanged comment has the same imprecision, and "follows the component's own update" is closer to what React does.
A viewport with no scrollable axis tracks whether it holds focus with focusin and focusout listeners. When focus moved between two of its descendants just after the component's own update, both events set the same value again. React then rendered the component once more before it bailed out, so the update cost two commits. The focus setters now skip a value the state already holds.
ca60fa4 to
ce5ef53
Compare
There was a problem hiding this comment.
Approved pending CI: CI has not run on this head yet. The pull request is a draft from a fork, so CI starts once it is marked ready for review and a maintainer adds the ci:run label.
The changeset and the setIfChanged comment now describe what the change does: the hand-off in the new test drops from two commits to one, and a ScrollableArea's first focus move after its own update no longer renders again. The new test fails without the guard, and 8 existing focus cases fail if the guard stops recording the value it wrote.
User impact
A component built on
useScrollableArea, such as ScrollableArea or BottomSheet, can render once more when focus moves between two descendants of a fitting viewport. It does when the move comes just after the component's own update. In the DateInput bottom sheet, the month title's focus hand-off then costs two commits instead of one.Problem and solution fit
The fix: the focus setters skip a value the state already holds.
Expected behavior and authority
#6314. Before it, the hook read focus during render, and a focus move set no state.Smallest restoration
useScrollableAreakeeps the last focus value it set in a ref. Its three focus setters (the listener, the detach cleanup and the measurement) set state only when the value changes.Evidence
useScrollableArea.test.tsxfails on main. The component's own update moves focus from one button to another inside the area, and costs two commits.Scope
Testing
This head, ce5ef53, rewords only the changeset, one doc comment and the commit message. At this head,
pnpm check:changesetsand Prettier pass. Its code is the same as 6a9ec5c, where these runs happened:pnpm -F @astryxdesign/core typecheck,pnpm check:knowledgeandpnpm check:changesetspass.pnpm lint:strict: 0 errors.webkit-container.mjswith CI's four CPUs: 10 passed, 9 skipped.