-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Specify the ability to scroll to increase/decrease <input type=number> #10911
Comments
cc @whatwg/forms |
A few minor clarifications:
Nit: strictly speaking, Chrome/Safari also seem to support modifying the number-field if there's some other element that contains/overlaps the input element that has a But ideally if we were to formalize this opt-in, then I think it would make sense to condition this on the input element itself.
Back when we implemented, other browsers had the same bug (same accidental opt-in) as they do today, FWIW -- at least, I confirmed that this is true for Chrome 55 (released in 2016) per https://bugzilla.mozilla.org/show_bug.cgi?id=1939377#c9 EDIT: going back further in history, though, it looks there was actually a point in history where other browsers lacked the event-listener-based opt-in mechanism. This was likely an unintended change, but it's brought us to the world we live in now. :) |
Something to consider if this officially becomes opt-in via a <input type="number" id="input">
<script>
input.addEventListener("wheel", e => e.preventDefault())
</script> So if this becomes conditional on the presence of a |
Colleagues and I discussed this and are considering removing this functionality as it doesn't match any of Apple's platform behaviors. It also doesn't seem that useful. Was there a particular reason Firefox wanted to match this functionality? |
Adding a little detail, since I've been investigating this behavior today. React eagerly adds a |
Not especially -- just for interop with Chrome/Safari, mostly. We just got a bug report after we turned off this functionality, where a user was expecting mousewheel-scrolling to change the focused number-field's value (on a site that happened to have a wheel event-listener on the number field), because it was working in Chromium/WebKit and had been working in Firefox until recently. It's not entirely clear if the site expects/intends for this to happen, but the user at least noticed that it had stopped working in Firefox and perceived that as a bug. Here's a screencast of the user's expected-results in Chrome: |
We also had a bug-comment with some worries that this behavior might be impossible for webdevs to polyfill, precisely because of the fact that browsers do this on their own (and hence the browsers' value-adjustment might stack on top of the site's value-adjustments). That concern had led me to believe we needed to align on this, so that authors-who-want-this-behavior could have a way to get it. However: I just attempted a polyfill and found that this concern isn't actually an issue; |
I wrote a series of test pages for this with various wheel event listeners. You can find it here: https://harmonious-quaint-cat.glitch.me/. Based on the behavior I'm seeing in Chromium, it seems that wheel event listeners are passive: false by default (vs passive: true like normal) when applied to a |
We in Blink observed the same thing @sfortiner observed, and this feels more like a bug than a deliberate opt-in mechanism. The facts that WebKit has removed the wheel event behavior and Firefox didn't have this behavior in the past suggest to me Blink should probably do the same. For sake of compat, I would love to know why React has the "opt-in" @WickyNilliams mentioned...anyone knows? |
I think it's a result of their synthetic event system. I raised an issue in the react repo here facebook/react#32156 |
What is the issue with the HTML Standard?
Both Chrome and Safari support increasing or decreasing the value of
<input type=number>
by scrolling the mouse wheel only wheninput
element need to be focused.input
.And they now provide an opt-in mechanism (perhaps unexpectedly ?),
wheel
ormousewheel
event handler registered.See the example of https://bug1939377.bmoattachments.org/attachment.cgi?id=9445400
We attempted to implement the same behavior without the opt-in mechanism in Gecko in bug 1261673 (I believe other browsers behaved like that at the time). However, we realized it might be a footgun as users might accidentally submitted a form with the wrong amount because of this and the original case in bug 1261673 doesn't work on other browser anymore, so we disabled this behavior in bug 1741469.
Now, we’ve noticed Chrome/Safari have an opt-in mechanism (not sure if it is intentional though as they are now considered a bug per https://bugs.webkit.org/show_bug.cgi?id=244240#c3 and https://issues.chromium.org/issues/40859979#comment8). However, this opt-in mechanism has likely prevented scroll-to-change-input-value from causing too much trouble.
It would be nice to specify the expected behavior in the spec to ensure consistency across browsers.
The text was updated successfully, but these errors were encountered: