-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add Esc key behavior to Reports search similar to SearchRouter #81072
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
base: main
Are you sure you want to change the base?
Conversation
| } | ||
| }, []); | ||
|
|
||
| useKeyboardShortcut(CONST.KEYBOARD_SHORTCUTS.ESCAPE, handleEscapeKey, { |
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.
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.
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: 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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! |
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