Skip to content

[CP Staging] Revert "fix: [Web] Focus restoration mechanism on back navigation (#76921)"#85887

Merged
MonilBhavsar merged 1 commit intomainfrom
revert-79834-fix/76921-focus-restoration-clean
Mar 20, 2026
Merged

[CP Staging] Revert "fix: [Web] Focus restoration mechanism on back navigation (#76921)"#85887
MonilBhavsar merged 1 commit intomainfrom
revert-79834-fix/76921-focus-restoration-clean

Conversation

@marcaaron
Copy link
Contributor

@marcaaron marcaaron commented Mar 19, 2026

Reverts #79834

$ #85866
$ #85874
$ #85878
$ #85886
$ #85896
$ #85895

@github-actions
Copy link
Contributor

🚧 @marcaaron has triggered a test Expensify/App build. You can view the workflow run here.

@github-actions

This comment has been minimized.

@codecov
Copy link

codecov bot commented Mar 19, 2026

Codecov Report

❌ Looks like you've decreased code coverage for some files. Please write tests to increase, or at least maintain, the existing level of code coverage. See our documentation here for how to interpret this table.

Files with missing lines Coverage Δ
src/App.tsx 100.00% <ø> (ø)
src/components/ApprovalWorkflowSection.tsx 0.00% <ø> (ø)
src/components/ConfirmModal.tsx 100.00% <100.00%> (ø)
src/components/PopoverMenu.tsx 81.86% <100.00%> (+0.88%) ⬆️
src/components/ThreeDotsMenu/index.tsx 90.90% <ø> (+14.07%) ⬆️
...c/hooks/useSyncFocus/useSyncFocusImplementation.ts 100.00% <ø> (ø)
src/libs/Navigation/NavigationRoot.tsx 76.92% <ø> (-0.26%) ⬇️
...omposerWithSuggestions/ComposerWithSuggestions.tsx 58.40% <ø> (+0.84%) ⬆️
src/pages/tasks/NewTaskPage.tsx 0.00% <ø> (ø)
src/pages/workspace/WorkspaceNamePage.tsx 0.00% <ø> (ø)
... and 7 more
... and 11 files with indirect coverage changes

@MonilBhavsar MonilBhavsar marked this pull request as ready for review March 20, 2026 05:24
@MonilBhavsar MonilBhavsar requested review from a team as code owners March 20, 2026 05:24
@melvin-bot melvin-bot bot requested review from JmillsExpensify and cristipaval and removed request for a team March 20, 2026 05:24
@melvin-bot
Copy link

melvin-bot bot commented Mar 20, 2026

@cristipaval Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button]

@MonilBhavsar MonilBhavsar changed the title Revert "fix: [Web] Focus restoration mechanism on back navigation (#76921)" [CP Staging] Revert "fix: [Web] Focus restoration mechanism on back navigation (#76921)" Mar 20, 2026
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6baa39b1c4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

}
inputRef.current?.focus();
});
isWindowReadyToFocus().then(() => inputRef.current?.focus());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Avoid stealing focus in deferred auto-focus

The hook now always executes inputRef.current?.focus() after isWindowReadyToFocus() resolves, even if focus has already moved to another interactive element in the meantime. On web, this causes back-navigation/restored-focus flows (and any user-initiated focus change during the delay) to be overridden by the input, producing unexpected focus jumps across the many screens that use useAutoFocusInput.

Useful? React with 👍 / 👎.

return;
}

ref.current?.focus({preventScroll: true});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Prevent useSyncFocus from overriding existing DOM focus

useSyncFocusImplementation now calls ref.current?.focus(...) unconditionally whenever isFocused is true, without checking whether another element is already focused. In keyboard-navigation and modal-close scenarios, this can immediately steal focus from the element that was intentionally restored, breaking expected tab order and causing visible focus flicker.

Useful? React with 👍 / 👎.

@MonilBhavsar MonilBhavsar merged commit a56df80 into main Mar 20, 2026
41 of 48 checks passed
@MonilBhavsar MonilBhavsar deleted the revert-79834-fix/76921-focus-restoration-clean branch March 20, 2026 05:44
@melvin-bot melvin-bot bot added the Emergency label Mar 20, 2026
@melvin-bot
Copy link

melvin-bot bot commented Mar 20, 2026

@MonilBhavsar looks like this was merged without a test passing. Please add a note explaining why this was done and remove the Emergency label if this is not an emergency.

@MonilBhavsar
Copy link
Contributor

Straight revert

@github-actions
Copy link
Contributor

🚧 @MonilBhavsar has triggered a test Expensify/App build. You can view the workflow run here.

@OSBotify
Copy link
Contributor

✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release.

OSBotify pushed a commit that referenced this pull request Mar 20, 2026
…-restoration-clean

[CP Staging] Revert "fix: [Web] Focus restoration mechanism on back navigation (#76921)"

(cherry picked from commit a56df80)

(cherry-picked to staging by cristipaval)
@OSBotify OSBotify added the CP Staging marks PRs that have been CP'd to staging label Mar 20, 2026
@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/cristipaval in version: 9.3.41-2 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

@OSBotify
Copy link
Contributor

🚀 Deployed to production by https://github.com/cristipaval in version: 9.3.41-4 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

@OSBotify
Copy link
Contributor

🚀 Cherry-picked to staging by https://github.com/cristipaval in version: 9.3.42-0 🚀

platform result
🕸 web 🕸 success ✅
🤖 android 🤖 success ✅
🍎 iOS 🍎 success ✅

Bundle Size Analysis (Sentry):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CP Staging marks PRs that have been CP'd to staging Ready To Build

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants