-
Notifications
You must be signed in to change notification settings - Fork 3.6k
fix: [Web] Focus restoration mechanism on back navigation (#76921) #79834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mavrickdeveloper
wants to merge
18
commits into
Expensify:main
Choose a base branch
from
mavrickdeveloper:fix/76921-focus-restoration-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+5,927
−63
Open
Changes from 15 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
cc6d020
fix: ensure focus restoration on back navigation (#76921)
mavrickdeveloper 383fd2a
refactor: use state-based validation for focus restoration (#76921)
mavrickdeveloper ec56985
fix(ConfirmModal): defer keyboard check to trap activation time
mavrickdeveloper 170a84c
fix(NavigationFocusManager): prioritize exact text matches over prefi…
mavrickdeveloper b31475f
fix(focus): harden focus restoration paths and add regression coverage
mavrickdeveloper 569e1f9
fix(focus): make popover keyboard focus deterministic and HMR-safe
mavrickdeveloper 1ed0d06
Merge remote-tracking branch 'origin/main' into fix/76921-focus-resto…
mavrickdeveloper 21dec14
Merge remote-tracking branch 'origin/main' into fix/76921-focus-resto…
mavrickdeveloper dd3a68c
Merge remote-tracking branch 'origin/main' into fix/76921-focus-resto…
mavrickdeveloper 1b8a7f0
test: add integration tests for ConfirmModal and ButtonWithDropdownMe…
mavrickdeveloper 64790cb
test: update focus restoration and navigation test suites
mavrickdeveloper 93d2d94
test: add accessibility and focus unit tests and trim redundant navig…
mavrickdeveloper 3e91814
fix: resolve CI blockers for ESLint, typecheck, spellcheck, and Prettier
mavrickdeveloper 06e1957
fix: inline web logic in blurActiveInputElementTest to avoid jest-exp…
mavrickdeveloper a7e94c6
style: apply Prettier formatting to match CI lockfile dependencies
mavrickdeveloper 4c56440
Merge remote-tracking branch 'origin/main' into fix/76921-focus-resto…
mavrickdeveloper 826d7ae
NAB: Test File Names Don't Follow Existing Convention
mavrickdeveloper 7e519ab
Missing wasOpenedViaKeyboard in React.memo Comparison
mavrickdeveloper File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| type InitialFocusParams = { | ||
| isOpenedViaKeyboard: boolean; | ||
| containerElementRef: unknown; | ||
| }; | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| function getInitialFocusTarget(_params: InitialFocusParams): HTMLElement | false { | ||
| return false; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| function restoreCapturedAnchorFocus(_capturedAnchorElement: HTMLElement | null): void {} | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| function shouldTryKeyboardInitialFocus(_isOpenedViaKeyboard: boolean): boolean { | ||
| return false; | ||
| } | ||
|
|
||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| function isWebPlatform(_platform: string): boolean { | ||
| return false; | ||
| } | ||
|
|
||
| export {getInitialFocusTarget, restoreCapturedAnchorFocus, shouldTryKeyboardInitialFocus, isWebPlatform}; |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔴 Critical Issue: Forbidden Type Casting (
as unknown as HTMLElement)Caution
Type casting is forbidden per Expensify's STYLE.md. This PR introduces a double cast in
ButtonWithDropdownMenu.Per the STYLE.md Refs section, when you need DOM methods on a RN ref, declare the ref as a union type and use proper narrowing:
Bug if not addressed: The double cast silences TypeScript entirely. If
dropdownAnchor.currentis not anHTMLElementon native platforms, calling.focus?.()would fail silently or crash.