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

Configure keys with config object #4281

Open
peterkogo opened this issue May 16, 2024 · 1 comment
Open

Configure keys with config object #4281

peterkogo opened this issue May 16, 2024 · 1 comment
Assignees
Labels
enhancement svelte svelte flow related v12

Comments

@peterkogo
Copy link
Member

peterkogo commented May 16, 2024

It wildly differs how people embed React/Svelte Flow into web apps, which inevitably leads to keys either not working or working even though the flow is blurred.
The solution for this is to make keys actually configurable to use a specific DOM node, so people are able to decide for themselves.

@peterkogo peterkogo added refactoring svelte svelte flow related v12 labels May 16, 2024
@peterkogo peterkogo self-assigned this May 16, 2024
@peterkogo peterkogo changed the title Revert to window pointer events Revert to window level event listeners May 16, 2024
@peterkogo peterkogo changed the title Revert to window level event listeners Configure keys with config object Jun 3, 2024
@peterkogo
Copy link
Member Author

Hm, maybe we are really overcomplicating things here... the available key options are deleteKeyCode, selectionKeyCode, multiSelectionKeyCode, zoomActivationKeyCode and panActivationKeyCode.

deleteKeyCode is the only one which fires an action right away. All other keys are just modifiers which do nothing if you don't interact with the flow directly. In a case of a collision, I think it's effortless to prevent key events from React Flow by setting the key code temporarily to null.

So I believe this issue is just about the deleteKeyCode and all other key handlers should be applied to the document or maybe even the window to observe modifier keys before the flow was in focus.

In the case of deleteKeyCode I am also questioning what the choice of a target really does here.
In the case of a modal inside an RF Panel: setting the target to the React Flow root would not prevent accidentally deleting something, and targeting something deeper down the flow would tank usability. Imagine clicking a button and delete does not work until you click on the viewport again.
If the modal is outside React Flow, deletion would not be triggered if the flow is out of focus. Thus, you'd need to either set the focus programmatically or interact with the flow to allow deletions again, which both sound like viable options.

What do you think @moklick

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

No branches or pull requests

1 participant