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

Have to clear field before typing new value on Firefox and IE11 #92

Closed
TechN8 opened this issue Jul 22, 2020 · 11 comments
Closed

Have to clear field before typing new value on Firefox and IE11 #92

TechN8 opened this issue Jul 22, 2020 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@TechN8
Copy link

TechN8 commented Jul 22, 2020

The getSelectionString function in Input.js uses window.getSelection() which does not work in fields on Firefox or IE. This results in the inability to over-type numbers in the hours input field.

Please consider using HTMLInput.selectionStart, HTMLInput.selectionEnd and HTMLInput.value to extract the selection text instead.

Let me know if you'd like me to write a PR for this change.

function getSelectionString() {
  if (typeof window === 'undefined') {
    return null;
  }

  return window.getSelection().toString();
}
@TechN8
Copy link
Author

TechN8 commented Jul 22, 2020

In looking into this a bit more, I see that selectionStart and selectionEnd don't work on Chrome. So my suggested fix won't work for number fields. There may not be a cross-browser way to do this without a polyfill or browser detection.

@devinekadeni
Copy link

is there any solution for this issue? Currently I'm facing the same problem in firefox

@wojtekmaj
Copy link
Owner

I think selectionStart, selectionEnd actually works on Chrome, but not for number inputs. We're getting rid of numer inputs though in #88 - only it goes veeeery slowly due to personal reasons of mine.

@wojtekmaj wojtekmaj added the bug Something isn't working label Nov 26, 2020
@TechN8
Copy link
Author

TechN8 commented Dec 11, 2020

Subscribed to #88 thanks!

@dannypaz
Copy link

dannypaz commented Jan 6, 2021

@wojtekmaj let us know how we can help. This is something I recently ran into and would love to resolve

@github-actions
Copy link
Contributor

This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this issue will be closed in 14 days.

@github-actions github-actions bot added the stale label Aug 30, 2021
@thmi-inx
Copy link

Reacting to the stale label: This is still an issue and from a UX and Accessibility point of view a quiet mayor one.

@wojtekmaj wojtekmaj removed the stale label Sep 1, 2021
@wojtekmaj
Copy link
Owner

wojtekmaj commented Sep 1, 2021

Absolutely agree. Removed the label.

Investigated further. Here's where we are at:

  • selectionStart, selectionEnd are null on number inputs on modern browsers. On IE11 it actually works. So we can't use just that.
  • window.getSelection() does not work for text selected in form fields on Firefox due to this bug: https://bugzilla.mozilla.org/show_bug.cgi?id=85686 that has been opened 21 22 23 years ago and is yet to be resolved.

wojtekmaj added a commit that referenced this issue Sep 1, 2021
@wojtekmaj
Copy link
Owner

Alright, fixed the issue on IE11 since it actually (contrary to the spec) supports selectionStart, selectionEnd on inputs with type="number". I have no idea how to work around this on Firefox, though.

My best idea is to simply skip this check for Firefox and let users type in invalid values in some cases, as this seems to be less harmful than them being unable to type over values.

@riffbyte
Copy link

riffbyte commented Nov 3, 2021

@wojtekmaj thanks for the fix!

Can you tell when can the fix be pushed into a new release?

@wojtekmaj
Copy link
Owner

Eh, sure, why not make one soul happy today. Released 4.4.4 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants