Add Esc key behavior to Reports search similar to SearchRouter#81072
Add Esc key behavior to Reports search similar to SearchRouter#81072
Conversation
| } | ||
| }, []); | ||
|
|
||
| useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, handleEscapeKey, { |
There was a problem hiding this comment.
this change lgtm, but should we use the search inputs onKeyDown event so that we arent adding a global listener?
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c0f6dc7cd9
ℹ️ 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".
| const handleEscapeKey = useCallback(() => { | ||
| if (textInputRef.current?.isFocused()) { | ||
| textInputRef.current.blur(); | ||
| } | ||
| }, []); | ||
|
|
||
| useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, handleEscapeKey, { | ||
| captureOnInputs: true, | ||
| shouldBubble: false, |
There was a problem hiding this comment.
Avoid swallowing Escape when input not focused
Because useKeyboardShortcut defaults to shouldPreventDefault=true and shouldBubble=false (see src/hooks/useKeyboardShortcut.ts), this handler will consume every Escape keypress on the Search page even when textInputRef isn’t focused (the callback no-ops). That prevents the global Escape handler in AuthScreens from running, so pressing Escape won’t dismiss modals/RHP overlays opened from the Search page unless they register their own Escape handler. Consider only activating the shortcut while the input is focused or allowing the event to bubble.
Useful? React with 👍 / 👎.
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.
|
|
@JS00001 ready again! |
JS00001
left a comment
There was a problem hiding this comment.
LGTM, thanks for fixing this
Reviewer Checklist
|
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/JS00001 in version: 9.3.11-19 🚀
|
|
🚀 Deployed to production by https://github.com/Julesssss in version: 9.3.12-1 🚀
|
Explanation of Change
I thought it was inconsistent that the pressing Escape when focused on the Search bar in the Reports page didn't remove focus like the chat switcher search bar, so tweaking that.
Video below is using CMD + K to focus, and then Esc to unfocus:
Screen.Recording.2026-01-30.at.3.09.01.PM.mov
Fixed Issues
$
PROPOSAL:
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectioncanBeMissingparam foruseOnyxtoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))npm run compress-svg)Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari