Repository navigation
fix(smart-toolbar): keep keyboard focus after Remove and Restore in the phone sheet - #75
Merged
Merged
Conversation
The phone status pill spans the docked bar's width 8px above it, in the band where the presence and Discord/GitHub/Privacy chips float, so a refused "/" pick, a removed format's Undo or an unavailable cell's reason covered them. Hide the chips while the bar holds a pill, as they already hide for the selection bar; they come back when it closes.
# Conflicts: # CHANGELOG.md
# Conflicts: # CHANGELOG.md
A "/" typed while an earlier fetch of the menu chunk was still failing (the chunk runtime fetches a failed chunk once more, a moment later) joined that fetch. When it failed, nothing loaded the chunk again while the menu stayed open, so the menu never showed even once the chunk could load. A failed load is now fetched once more straight away.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
In the phone "Text format" sheet (Aa), Your formats' Remove buttons and Restore ‘X’ (PR #54) unmount the button you activate. A hardware-keyboard user (tablet or phone with a keyboard, switch access) lost their place: focus ended up on the sheet itself, and the next Tab started again from the top of the sheet.
Focus now moves to a sensible target:
tabindex="-1"set at focus time, with the buttons' 2px focus ring and a scroll margin so the ring clears the sheet's top edge).preventDefaulton mousedown, so a tap never focused them, and focus is only moved when the activated button had it.announce,remove-format.tsandsaved-formats.tsare untouched.Root cause
DIVitself (observed:document.activeElementwas the dialog, notbody), so the place in the sheet is lost. Nothing chose a successor.SheetFormatsrecords a one-shot intent in the click handler,{ removedAt }or{ restored }, and only whenevent.currentTargethad focus. AuseLayoutEffectkeyed on the saved formats consumes it before paint.activeElementis an ancestor of the list (the dialog or body). A restore that waits on the engine chunk therefore never pulls focus from somewhere the user moved meanwhile.How verified
mobile-bar-followups.spec.ts("Your formats keep keyboard focus in the sheet", plus the cap-link case). All four fail on main and pass now:--repeat-each=5: 20/20 on Chromium.mobile-bar,mobile-bar-followupsandpaint-formatpass 96/96 on Chromium (--workers=2).bun run check: the only warnings are 7 that were already on main, in other files.bun run lintandbun run typecheckare clean.bun run test: 1234/1234 on the rerun. The first run had 1 failure in a file this PR does not touch (shared machine), and no unit test covers these files.wf2/phone-restore-focus/:Budgets
formats/format-preview, which is unchanged, soPALETTE_BUDGETwas not needed.Follow-ups