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

Add option to not select input when hitting Escape #782

Open
mpsijm opened this issue Mar 4, 2024 · 2 comments
Open

Add option to not select input when hitting Escape #782

mpsijm opened this issue Mar 4, 2024 · 2 comments

Comments

@mpsijm
Copy link

mpsijm commented Mar 4, 2024

Given that isCancellable: false and selectOnFocus: false:

Current behavior

When I hit Escape, the input value is selected.

Expected behavior

When I hit Escape, the input value should not be selected.

Steps to reproduce the problem

  1. Use autoNumeric version v4.10.4
  2. In both Firefox 123 and Chrome 122
  3. On the Arch Linux operating system
  4. Then instantiate the autoNumeric object with the following options:
new AutoNumeric(domElement, { isCancellable: false, selectOnFocus: false });
  1. Then my computer exploded, for real. If I type some numbers and hit Escape, the input value is selected.

Reproduction example: https://jsfiddle.net/Lxh8aned/

Code exploration

I found this code:

            // ...and lastly we update the caret selection, even if the option `isCancellable` is false
            this.select();
            //TODO Add an option to select either the integer or decimal part with `Esc`

I would expect that the update to the caret selection would at least follow the options that already exist, e.g. selectOnFocus and selectNumberOnly.

@AlexandreBonneau
Copy link
Member

I fail to see how selectOnFocus is related to the Escape key allowing to select when hitting the Escape key.
Also, as per the documentation, isCancellable also allow the Esc key to select everything:
2024-03-06_103612_Screenshot

So those options and behaviors are working as expected, and will not change.

However there could be a use case where hitting the Esc key only cancel the changes (or not), and do not select anything.

@mpsijm
Copy link
Author

mpsijm commented Mar 6, 2024

Yes, it feels like those two options could be separated, thanks for the elaboration 🙂

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

No branches or pull requests

2 participants