-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
Windows/macOS: Resolves #7520: Search field doesn't get focus when pressing Ctrl+F #7529
Windows/macOS: Resolves #7520: Search field doesn't get focus when pressing Ctrl+F #7529
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
recheck |
@@ -13,7 +13,6 @@ export const runtime = (comp: any): CommandRuntime => { | |||
comp.editorRef.current.execCommand({ name: 'search' }); | |||
} else { | |||
comp.setShowLocalSearch(true); | |||
if (comp.noteSearchBarRef.current) comp.noteSearchBarRef.current.wrappedInstance.focus(); |
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.
Now that you made focus() public, does it work if you just replace this with comp.noteSearchBarRef.current.focus()
?
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.
@laurent22 no it doesn't. We can't focus immediately after calling comp.setShowLocalSearch(true)
because React needs some time to rerender, so I used the useEffect
instead and called noteSearchBarRef.current.focus()
in the useEffect
.
Just another caveat... After pressing Ctrl + F once, my cursor moves in the local search area, but if I move my cursor to the note and press Ctrl + F once again (while in note area with the local search already open), the cursor doesn't move back into the local search. |
Thank you @sanskarfc . I pushed a change to address this. Thank you @laurent22 also for your review. Looking forward to any additional feedback. |
Looks good now, thanks for fixing this! |
Fixes #7520
Solution
I fixed this by adding a
useEffect
that auto focuses the search input after it is opened from the command execution.Electron.-.Joplin.DEV.-._Users_macbookair_.config_joplindev-desktop.-.24.December.2022.mp4