Skip to content
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] About matching key sequences #181

Closed
NepeinAV opened this issue May 19, 2019 · 2 comments
Closed

[QUESTION] About matching key sequences #181

NepeinAV opened this issue May 19, 2019 · 2 comments

Comments

@NepeinAV
Copy link

Hello Aleck! I have a question about how react-hotkeys matching key sequences like 'ctrl+alt+p'.
In my project i have the structure of components like:

<HotKeys globalKeys> ... <HotKeys editorKeys> ... </HotKeys>

In globalKeys i have, for example, key sequence 'CTRL+ALT+ARROWDOWN'.
Also in editorKeys i have just 'ARROWDOWN' sequence.
Now focus on editorKeys.

Question

Why where I press 'CTRL+ALT+ARROWDOWN' sequence react-hotkeys finds sub-match of it

HotKeys (F3📙-E253💚-C0🔺-P1⭐️:) Found action that matches 'Alt+ArrowDown+Control' (sub-match: 'ArrowDown'): DOWN. Calling handler . . .

and executing the 'ARROWDOWN' handler instead of 'CTRL+ALT+ARROWDOWN' handler and how to prevent sub-matching?

Thank you!

@greena13
Copy link
Owner

Hello @NepeinAV, thanks for taking the time to clarify what the expected behaviour is and apologies for the delay in responding.

It seems you are among a growing number of users requesting that the library work in a different way than it currently does: That the length of the key combination be given priority over where its definition is in the focus tree. Currently HotKey and GlobalHotKey components that are closest to the component that is currently in focus, will have their keymaps and handlers inspected first, and if a match is found, then react-hotkeys looks no further. I am guessing this is why the shorter ArrowDown submatch is occurring in your case.

I am planning on obliging this growing sentiment, but it will be a while before I attempt to tackle it.

I'm going to close this issue for now, as for the purpose of addressing it, it appears to be a duplicate of #161. But feel free to ask further questions if anything remains unclear.

@greena13
Copy link
Owner

greena13 commented Jun 2, 2019

@NepeinAV, as of v2.0.0-pre7 sub-matches are ignored, so react-hotkeys should behave as you're expecting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants