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

Input fields within the selection boundary cannot be focused on #72

Closed
au-re opened this issue Feb 25, 2020 · 3 comments
Closed

Input fields within the selection boundary cannot be focused on #72

au-re opened this issue Feb 25, 2020 · 3 comments
Labels
question Further information is requested

Comments

@au-re
Copy link

au-re commented Feb 25, 2020

Do you want to request a feature or report a bug?

A bug

What is the current behavior?

When using selection-js, any input field within the selection boundary cannot be focused on.

If the current behavior is a bug, please provide the steps to reproduce and create a JSFiddle.

I created a codepen (couldn't get the jsfiddle to work) to illustrate the issue:
https://codepen.io/au_re/project/editor/ZbWWrj

What is the expected behavior?

Ideally you should still be able to focus input fields inside the selection boundary, or selectable elements

Your environment:

Selection-version: 1.6.0
Browser-version:  Firefox/Chrome
Operating-system:  Windows/Linux
@simonwep simonwep added the question Further information is requested label Feb 25, 2020
@simonwep
Copy link
Owner

This kind of wanted-behavior (let's not call it an issue) can be easily fixed via the beforestart event:

selection.on('beforestart', ({oe}) => {
    return oe.target.tagName !== 'INPUT';
});

beforestart gets fired before a selection takes place, inside of the event-handler you can decide whether a selection should be initiated or not. In your case you only want the user to make a selection if the target-element (where the user clicked) is not a input-element.

@au-re
Copy link
Author

au-re commented Feb 25, 2020

Thanks! I should read the documentation more carefully next time :/ Great job by the way, this library is super useful!

@au-re au-re closed this as completed Feb 25, 2020
@simonwep
Copy link
Owner

You're welcome! I have to admit that the event-section in the docs isn't very extensive - I've just added a few inline-comments to the event-examples to show how each event could be used :)

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

No branches or pull requests

2 participants