Repository navigation
fix(NavigationStack): a push keeps focus a person moved into the new screen - #12009
Conversation
…screen When a push settled, the stack moved focus to the new screen's title whenever focus was inside the stack. Focus a person had moved into the new screen during the push, such as a tap on its field, was taken away, and on a phone the keyboard closed. The settle now leaves focus that already sits in the screen now on top. The title still takes focus when focus is detached or on the previous screen or the bar. Core's isFocusLost is unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec a7e6080 |
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC |
|---|---|---|
| lab/NavigationStack | 85.2 kB (+54 B) · 1.5 kB CSS (0) | — |
| lab/NavigationScreen | 85.2 kB (+53 B) · 1.5 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-a11y for Accessibility, ci:run-rtl for RTL.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved pending CI: CI skips drafts, so it has not run on this head and runs once the pull request is marked ready.
The new early return in focusAfter keeps focus a person moved into the new screen: the new test fails on main and passes here, and a Chromium touch run shows the settle moving focus from the field to the title on main but not on this head.
- Non-blocking:
NavigationStack.doc.mjsand theNavigationStackJSDoc still say a push always moves focus to the new screen's title; consider adding "unless focus is already in that screen".
Two smaller non-blocking notes are inline.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim: a field tapped during a push lost focus to the bar title when the push settled. Verified: the new test fails on
mainwith focus on the title, and a Chromium touch run shows the same. - Claim: on a phone the keyboard then closed. Verified as far as the code goes (focus moves from the input to a heading); not checked on a device.
- Claim: after the change, focus the person moved into the new screen stays. Verified: the test passes on this head, and the Chromium run keeps focus on the field.
- Claim: the settle moves focus whenever
isFocusLostis true, which includes focus anywhere inside the stack. Verified:NavigationStack.tsx:1337and Core'sfocusReturn.ts:31-36. - Claim: the fix leaves focus already inside the screen now on top, pushed or revealed. Verified:
NavigationStack.tsx:1340-1349. - Claim: the title still takes focus when focus is detached, on the previous screen or in the bar. Verified: only the top card returns early, and the bars render outside the cards.
- Claim: a pop still returns focus to the control that pushed. Verified: the existing focus test passes and the pop branch is unchanged.
- Claim: Core's
isFocusLostis unchanged. Verified: no Core file changes. - Claim: the accessibility record makes WCAG 2.2 A and AA the baseline, including 2.4.3 Focus Order. Verified; reading the settle as a 2.4.3 failure is the description's interpretation, and a Lab change does not need it.
- Claim: a spec owner confirmed this as a records-decided repair. Verified: an engineering owner commented
/approve-specfor this head, and the spec-owner status is green. - Claim: the pending NavigationStack record proposal (#12005) states the full rule. Verified: its draft FR13 says a change never takes focus the person moved into the new top screen.
- Claim: one early return with a comment, one jsdom test, no public API change. Verified.
- Claim: no changeset because
@astryxdesign/labis private. Verified: the package is private and canary-only, and changeset coverage skips it. - Claim: red first, and all NavigationStack unit suites pass (40 tests in 2 files). Verified by running both.
- Claim: strict eslint reports no errors on the changed files. Verified by running it.
- Claim: a device take follows in a comment. Not posted yet at this head; no rule requires it.
- Claim: #12001 shares no line with this change, and #12002 is a preview not for merge. Verified: #12001 changes styles near line 308 and a test near line 109.
- File
packages/lab/src/NavigationStack/NavigationStack.tsx: non-blocking, the top-card lookup also matches cards of a nested stack; the JSDoc at lines 815-816 still states the old rule. - File
packages/lab/src/NavigationStack/NavigationStack.test.tsx: non-blocking, thewaitForondata-navigation-toppasses at the push's commit, so the 600 ms sleep is the settle wait. - Consistency with unchanged
NavigationStack.doc.mjs: non-blocking, line 28 still states the old rule.
The check for focus already in the screen on top now reads the direct children of the stack's cards layer, so a stack nested in a covered screen, with an equal key, cannot answer for it. The test waits past the settle without a check that passes at the commit. The doc and the JSDoc say a push keeps focus already in the new screen.
|
/approve-spec 8e4d348 |
There was a problem hiding this comment.
Approved pending CI: CI is running on this head and its required checks have not finished yet.
The early return in focusAfter keeps focus a person moved into the new screen: the new test fails on main with focus on the bar title and passes here, and the existing focus tests still pass. Nothing at this head needs a change.
- Note: the early return also keeps focus that an
autoFocusfield on the pushed screen takes on mount, so screen-reader users arrive on that field rather than the title; the updated doc sentence covers this, though the description names only a tap.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules since the last review (0): none.
- Claim: a field tapped on the new screen during a push lost focus to the bar title when the push settled. Verified: the new test fails on
mainwith focus on the bar title. - Claim: on a phone the keyboard then closed. Accepted as stated from the iOS Simulator run in the description; consistent with focus moving from the field to a heading.
- Claim: after the change, focus moved into the new screen stays there. Verified: the new test passes on this head, and a Chromium touch run keeps focus on the field.
- Claim: the settle moves focus whenever
isFocusLostis true, which includes focus anywhere inside the stack. Verified:NavigationStack.tsx:1338and Core'sfocusReturn.ts:31-37. - Claim: the fix leaves focus already inside the screen now on top, pushed or revealed. Verified:
NavigationStack.tsx:1341-1351. - Claim: the title still takes focus when focus is detached, on the previous screen or in the bar. Verified: only this stack's top card returns early, and the bar renders outside the cards layer.
- Claim: a pop still returns focus to the control that pushed. Verified: the existing focus test passes and the pop branch is unchanged.
- Claim: Core's
isFocusLostis unchanged, so its other callers are unaffected. Verified: no Core file changes. - Claim: the accessibility record makes WCAG 2.2 A and AA the baseline, including Focus Order. Verified as the record's baseline; reading the settle as a Focus Order failure is the description's interpretation, and this Lab change does not need it.
- Claim: a spec owner confirmed this as a records-decided repair. Verified: an engineering owner commented
/approve-specfor this head, and the spec-owner status is green. - Claim: the pending NavigationStack record proposal (#12005) states the full rule. Verified: its draft FR13 says a change never takes focus the person moved into the new top screen.
- Claim: one early return with a comment, one jsdom test, no public API change, and no changeset because
@astryxdesign/labis private. Verified; the head also updates the doc description and the JSDoc, which the Evidence section names. - Claim: red first, and all NavigationStack unit suites pass (40 tests in 2 files). Verified by running both on this head.
- Claim: in the iOS Simulator, 3 of 3 runs on
mainmoved focus to the title and closed the keyboard, and 3 of 3 with the fix kept it, at the commit before this head. Accepted as stated; no applicable rule requires device evidence for this Lab change. - Claim: the physical iPhone's driver cannot tap inside the push window, so that run used the Simulator. Not checkable here; it changes no finding.
- Claim: the later commit narrows the lookup to this stack's own cards and updates the doc wording, and with no nested stack it reads the same card. Verified: only this stack's cards carry the screen attribute unless a stack is nested.
- Claim: strict eslint reports no errors on the changed files. Verified by running it.
- Claim: one defect is restored, with no tagalong, hidden API, default or interaction model, and no internal context in public text. Verified, apart from the
autoFocusnote above. - Claim: #12001 shares no line with this change, so the two land in either order, and #12002 is a preview not for merge. Verified: #12001 changes the card style near line 308 and adds a test near line 109.
- Claim: no release, because
@astryxdesign/labis private. Verified: its package manifest is private. - File
packages/lab/src/NavigationStack/NavigationStack.tsx: clear; the lookup reads only this stack's own cards. - File
packages/lab/src/NavigationStack/NavigationStack.test.tsx: clear; the 1200 ms wait is about twice the push settle in jsdom. - File
packages/lab/src/NavigationStack/NavigationStack.doc.mjs: clear; the description matches the JSDoc and the code.
Main moved past #12297 (CI planner budget); a clean merge, no conflicts.
|
/approve-spec 0a58ac1 |
There was a problem hiding this comment.
Approved pending CI: CI is running on this head and its required checks have not finished yet.
The early return in focusAfter keeps focus a person moved into the new screen: the new test fails on the current base with focus on the bar title and passes here, and the existing focus tests still pass. Nothing at this head needs a change.
- Note: the early return also keeps focus that an
autoFocusfield on the pushed screen takes on mount, so screen-reader users arrive on that field rather than the title; the updated doc sentence covers this, though the description names only a tap.
Claims and files checked
Review mode: same-head; reason: none
- Changed rules since the last review (0): none.
- Claim: a field tapped on the new screen during a push lost focus to the bar title when the push settled. Verified: the new test fails on the base with focus on the bar title.
- Claim: on a phone the keyboard then closed. Accepted as stated from the iOS Simulator run in the description; consistent with focus moving from the field to a heading.
- Claim: after the change, focus moved into the new screen stays there. Verified: the new test passes on this head.
- Claim: the settle moves focus whenever
isFocusLostis true, which includes focus anywhere inside the stack. Verified:NavigationStack.tsx:1338and Core'sfocusReturn.ts:31-37. - Claim: the fix leaves focus already inside the screen now on top, pushed or revealed. Verified:
NavigationStack.tsx:1341-1351. - Claim: the title still takes focus when focus is detached, on the previous screen or in the bar. Verified: only this stack's top card returns early, covered cards are inert, and the bar renders outside the cards layer.
- Claim: a pop still returns focus to the control that pushed. Verified: the existing focus test passes and the pop branch is unchanged.
- Claim: Core's
isFocusLostis unchanged, so its other callers are unaffected. Verified: no Core file changes. - Claim: the accessibility record makes WCAG 2.2 A and AA the baseline, including Focus Order. Verified as the record's baseline; reading the settle as a Focus Order failure is the description's interpretation, and this Lab change does not need it.
- Claim: a spec owner confirmed this as a records-decided repair. Verified: an engineering owner commented
/approve-specfor this head, and the spec-owner status is green. - Claim: the pending NavigationStack record proposal (#12005) states the full rule. Verified: its draft FR13 says a change never takes focus the person moved into the new top screen; the record is a draft.
- Claim: one early return with a comment, one jsdom test, no public API change, and no changeset because
@astryxdesign/labis private. Verified; the head also updates the doc description and the JSDoc, which the Evidence section names. - Claim: red first, and all NavigationStack unit suites pass (40 tests in 2 files), re-checked at this head. Verified by running both on this head.
- Claim: in the iOS Simulator, 3 of 3 runs on
mainmoved focus to the title and closed the keyboard, and 3 of 3 with the fix kept it, at an earlier commit of this pull request. Accepted as stated; no applicable rule requires device evidence for this Lab change. - Claim: the physical iPhone's driver cannot tap inside the push window, so that run used the Simulator. Not checkable here; it changes no finding.
- Claim: the later commit narrows the lookup to this stack's own cards and updates the doc wording, and with no nested stack it reads the same card. Verified: only this stack's cards carry the screen attribute unless a stack is nested.
- Claim: strict eslint reports no errors on the changed files. Verified by running it.
- Claim: one defect is restored, with no tagalong, hidden API, default or interaction model, and no internal context in public text. Verified, apart from the
autoFocusnote above. - Claim: #12001 shares no line with this change, so the two land in either order, and #12002 is a preview not for merge. Verified at #12001's current head: it changes the card styles near line 308 and adds a test near line 109; #12002 is an open draft.
- Claim: no release, because
@astryxdesign/labis private. Verified: its package manifest is private. - Commit message claim: the head is a clean merge of
mainwith no conflicts, aftermainmoved past #12297. Verified: the merge changes none of this pull request's files, and #12297 is in the merged base. - File
packages/lab/src/NavigationStack/NavigationStack.tsx: clear; the lookup reads only this stack's own cards. - File
packages/lab/src/NavigationStack/NavigationStack.test.tsx: clear; the 1200 ms wait is about twice the push settle in jsdom. - File
packages/lab/src/NavigationStack/NavigationStack.doc.mjs: clear; the description matches the JSDoc and the code.
Main brought in #12009, which touches NavigationStack.tsx and its test on other lines; a clean merge.
Main brought in #12009, which touches NavigationStack.tsx and its test on other lines; a clean merge.
* fix(NavigationStack): screen content stays under the bar A card was not a stacking context at rest, so a screen child with a z-index of 2 or more painted over the bar, whose z-index is 1, and covered its title and Back. Each card now isolates its content, as a transform already does during a transition, so transitions are unchanged. A jsdom check, a story with raised content under the bar and a browser case (title and Back hit by elementFromPoint, Back pops) cover it. * Merge main into PR #12001's branch Main moved past #12297 (CI planner budget); a clean merge, no conflicts. * test(NavigationStack): the raised-content case reads hits at rest, after will-change lets go The animator holds will-change on a card briefly after its last motion, and that alone makes a stacking context, so the browser case passed on the base too. It now waits until every card reads will-change: auto. The jsdom case is named after what it asserts. * Merge main into PR #12001's branch Main brought in #12009, which touches NavigationStack.tsx and its test on other lines; a clean merge.
…ds (meta#12010) * test(NavigationStack): a push whose commit blocks the main thread starts from its first frame A heavy screen holds the main thread for 300 ms in the task that pushes it. Two frames after the block, the pushed card must still be more than half the width from where it rests. Dated before the block, the push shows almost all of its travel at once. * fix(NavigationStack): a push or pop from rest starts when its task ends A push or a programmatic pop passed the time of its call to every animation, so a heavy commit or a later listener that held the main thread after the call made the transition skip ahead into its curve. A transition from rest now leaves the start to the animator: the browser commit dates it, and in an input event's own task it starts at the first frame after that task. A finger's release keeps its release time. The back chevron keeps the screens' clock. * fix(NavigationStack): the stack marks its own input task for the next-frame start The stack's capture handlers for clicks and key presses now mark the task they run in, and the next task clears the mark. A transition that one of them starts uses start: next-frame from that mark, because React may commit it in a microtask, after the browser has cleared window.event. window.event stays as the fallback for a push the app starts outside the stack. * fix(NavigationStack): the input-task fallback reads only a press's events The window.event fallback took any UIEvent, which includes focus, wheel, input and resize events. It now reads only the pointer, key and touch events a press dispatches, as its comment says. The clock comment is split into short sentences, and the input-task mark notes why it does not rely on window.event. * fix(NavigationStack): type the input-task fallback for the window constructors isDispatchingInput reads view.Event, which the Window type does not declare. Its parameter now takes the window with its globals, as ownerDocument.defaultView already is, so the Lab typecheck passes. * Merge main into PR meta#12010's branch Main moved past meta#12297 (CI planner budget); a clean merge, no conflicts. * test(NavigationStack): the blocked-push case reads the time since the block WebKit's first frames after a long task can take far longer than 16 ms, so two frames were not a fixed time into the push. The case now reads performance.now() with the position and checks that at least half of what the spring leaves at that time is still to travel, which a push dated before the block cannot meet. The activation-mark comment names the scripted click it serves. * Merge main into PR meta#12010's branch Main brought in meta#12009, which touches NavigationStack.tsx and its test on other lines; a clean merge. * test(NavigationStack): the blocked-push floor is the push's own spring leftAt was a 0.19 s critically damped spring from rest, so at WebKit's slower frames the floor asked for less than half of what the push leaves. It is now the file's push spring (OMEGA, starting at PUSH_VELOCITY), so a push dated inside the block fails at any frame delay.
…ys no second animation (#12004) * test(sandbox): a raw page that logs whether the platform animated a history back On a real phone, the page pushes two history entries and logs each popstate and Navigation API navigate event with its hasUAVisualTransition, and the display mode it runs in. It is the evidence page for NavigationStack skipping its own pop or push animation after a platform-animated traversal. * fix(NavigationStack): a platform-animated history back or forward plays no second animation When the platform has just animated a history traversal (Safari's edge swipe back or forward, an iOS Home Screen app's back gesture), the browser sets hasUAVisualTransition on the Navigation API navigate event and on popstate. The stack marks it for two frames, and the path change that traversal causes is applied at once: a pop drops the leaving screen with no slide, a push puts the new screen on top with no slide. Focus moves as after any settled push or pop. A traversal the platform did not animate still slides. * fix(NavigationStack): the traversal listeners attach with the container The popstate and navigate listeners now attach in the container ref callback on the element window, beside the modality tracker, and detach with it, so a stack moved to another document listens to its new window. The probe page keys screens by position and name, sets the path when the stack pops before it moves the history, and leaves its own two entries out of the stack path. * test(sandbox): the probe stack follows a back to the page's first entry The router marks the first history entry, so its state is neither null nor a stack path. The probe now skips only its own two step entries and treats any other entry without a path as the root. The component JSDoc names the exception to its animation. * Merge main into PR #12004's branch Main moved past #12297 (CI planner budget); a clean merge, no conflicts. * Merge main into PR #12004's branch Main brought in the merged NavigationStack fixes (#12009, #12010, #12001) on other lines of NavigationStack.tsx and its test; a clean merge. * Merge main into fix/navigationstack-ios-platform-back * chore(sandbox): drop the history-back probe page from this change The probe page served only the device takes. Without it this pull request changes the Lab NavigationStack and its test alone. * test(NavigationStack): a traversal that hides the stack before the mark clears leaves no mark * fix(NavigationStack): detaching the traversal listener clears the platform mark A container that detached within two frames of a browser-marked traversal kept the mark, so the next tap push or Back pop played no slide. * Merge main into fix/navigationstack-ios-platform-back
User impact
In an app built on Lab
NavigationStack, a person who tapped a field on the new screen while a push was still animating lost focus from that field when the push settled, because the bar title took it. On a phone the keyboard closed, so the person had to tap the field again. After this change, focus the person moved into the new screen stays where they put it.Problem and solution fit
focusAftermoves focus to the new screen's title whenever Core'sisFocusLost(container)is true. That function is true when focus is detached and also when focus is anywhere inside the stack, including inside the screen just pushed.focusAfterleaves focus that already sits inside the screen now on top (the pushed screen, or the screen a pop reveals). The title still takes focus when focus is detached, on the previous screen, or in the bar, and a pop still returns focus to the control that pushed. Core'sisFocusLostis unchanged, so its other callers are unaffected.Expected behavior and authority
spec:AST-020FR1 holds Core and Lab to WCAG 2.2 A/AA, which includes SC 2.4.3 Focus Order: focus that moves by script must keep the page operable. A settle that pulls focus out of the field the person just focused, and closes the phone keyboard, breaks that. The specification owner confirmed this as a records-decided repair. A pending NavigationStack record proposal (#12005, FR13) states the full rule, "never takes focus the person moved into the new top screen", for the owner's decision; this PR is the minimum repair that matches it.Smallest restoration
NavigationStack.tsx: one early return infocusAfter, with a comment.@astryxdesign/labis private.Evidence
keeps focus a person moved into the new screen before the push settlespushes a screen, focuses its field mid-push, waits for the settle, and checks that the field keeps focus. It fails on main (focus moves to the title) and passes with the change.moves focus to the new title after a push, and back to the pushing control after the popstill passes. All NavigationStack unit suites pass (40 tests in 2 files).Scope
Components: NavigationStack (lab)
Testing
vitest run packages/lab/src/NavigationStack: 40 passed, red first as above (re-checked at this head).eslint(strict) on the changed files: no errors.Overlap checked: #12002, #12001 (#12001 is a different defect in the same component, card stacking at rest in one style line, and shares no line with this change to
focusAfter; #12002 is a preview of the draft NavigationStack record, not for merge)Owner and land path
Owner: Cindy's Astryx gaps lane 3 (agent). Land path: Specs stamp as a defect repair, then CodeBunny review on the exact head, then ready, CI, and merge through the drain queue. It touches
NavigationStack.tsxon lines other than #12001's, so they land in either order. No release (@astryxdesign/labis private).