-
-
Notifications
You must be signed in to change notification settings - Fork 32
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
[Question] How to check if input is active/focused #1073
Comments
@calebchiam this sounds similar to #455 please let me know if your use case is the same. I’ve been considering making a breaking change to replace mousetrap.js since it’s a dead project. @mminer had raised the subject of useCapture in mousetrap. Would love to get your thoughts |
Interesting! -- I think my use case is actually in the 'opposite' direction; the problem is that my keyboard shortcuts may be alphanumeric (e.g. just the single 'Q' key) and I don't want these shortcuts to trigger when the command palette input is being used. In other words, some component external to the command palette needs to check the state of the input to figure out whether to fire off the keyboard shortcut, so |
Would the onChange prop work? onChange is a function that's called when the input value changes. It returns two values: the current value of the input field followed by the users typed input. The query ignores keyboard navigation and clicks |
The onChange prop doesn't let me know when the input is focused vs blurred (which is the state I'm interested), so it wouldn't be useful here. But don't worry about it! I ended up implementing a command palette from scratch (borrowing the styling from yours), so this change is not urgently needed from my end anymore. Thank you for responding though, and feel free to close this issue. |
Glad you found a solution |
Hi, I'm using the command palette on a page where keyboard shortcuts are used. I'd like to distinguish those keyboard inputs from those used when typing in the search input of the command palette.
May I ask if there is a good way to do this? From the docs, there doesn't to be a way to check if the input is currently active. One typical solution would be to pass a ref to the input component, but that's not currently exposed by the command palette. (Not that I think it should necessarily be exposed just for this specific use case.)
Thanks!
The text was updated successfully, but these errors were encountered: