-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Mouse events & disabled form controls #2368
Comments
Someone needs to define "hit testing" basically. That's the root of all these issues. |
??? Hit-testing is clearly working correctly here - it correctly hit-tests that you're over a disabled form control, and then swallows the mouse event. That's the issue here. |
Yeah, I got this confused with defining mouse events, which need hit testing to be properly defined (hit testing would tell them it's a disabled control, at which point they wouldn't dispatch the mouse event, but maybe would dispatch the pointer event in the same task). |
@RByers @jacobrossi any insight into where this weird behaviour comes from? |
Wow, this is news to me! Since the main thing you're talking about isn't actually defined by HTML, let's discuss over in w3c/pointerevents#177. Once we figure that out, let's come back to the |
Note that the issue description here is not quite right about what the "firefox behavior" is or the other browsers' behavior, afaict. See https://lists.w3.org/Archives/Public/public-html/2015Oct/0010.html |
It looks like Gecko basically stops preventing the dispatching of all events on disabled form controls while WebKit and Blink seem to simply ignore event listeners on disabled form controls. See https://gist.github.com/rniwa/bf0f1411d6b811fcb605e796498740f3 Gecko yields nothing while WebKit and Blink yields:
|
I updated my test case a bit (updated the gist). It looks like Gecko is simply truncating the event path at the first disabled form control. This behavior is saner than WebKit/Blink's. I do have a mild concern that preventing all events from being dispatched on a disabled form control might be a breaking change for some websites. Given WebKit/Blink only has this quirk for I'd also add that while WebKit/Blink behavior is very odd, it probably has the least effect to the rest of the event dispatching behavior so it might be something to consider. |
Blink has since changed behaviour for mouse events. http://output.jsbin.com/botohet/quiet - the listener here is on the window object (capturing phase). You get mouse/down/up events on the disabled button in Blink, whereas you don't in WebKit. |
You mean pointer events? I don't see any |
I'm getting both mouse & pointer events in 68 and 71. |
@rniwa apologies. It only fires mouse events with the "Experimental web platform" flag. |
It's 2019. With https://jsbin.com/cafidayeri/1/edit?html,js,console,output, Firefox seems to allow any synthetic events to be fired on the element itself, except Both browsers prevent Relevant WPT: https://github.com/web-platform-tests/wpt/blob/master/html/semantics/forms/attributes-common-to-form-controls/disabled-elements-01.html. This checks that synthetic non-
*: spec says “ |
For the record, @eps1lon ran into this, and @brendo tried to fix it, in jsdom: jsdom/jsdom#2665 and jsdom/jsdom#2681. This is quite the interop footgun... The test case there was very simple: just Oh wow, @TimothyGu posted a much larger analysis while I was writing this, I see :). /cc @tkent-google since I know he likes interop bugs and form controls. |
Based on what I tested on #5000, WebKit does not trigger click listeners. (But interestingly mutates checkboxes!) |
I want to share a case related to focus events. If you have a non-focusable element e.g. Dispatching click events on a disabled button will not execute click handlers on that button in Chrome. It will also not dispatch click events when calling A div without a tabIndex acts with regard to focus like a disabled button acts with regard to click. IMO I'd prefer to not prevent synthetic events. While this is a somewhat common footgun when writing tests I would always recommend using an imperative method if it exists rather than dispatching synthetic events. |
Firefox now seems to be shipping 2 different site patches to work around sites which depend on the Blink/WebKit behaviour here (c.f. bug 1653882). To me it seems hard to justify any course of action other than aligning the spec with the majority of implementations and updating Gecko to match. |
This one is for allowing more MouseEvents on disabled form controls, and that one is for the bubbling behavior on disabled form controls. I don't have strong feelings about keeping the other one open so if it helps you then please close it, but the separation is clear in my head. |
Hmm, could be good to change the title for this issue, but I don't have permission for that. (The current title sounds like it covers all issues regarding to mouse events and disabled form controls, and also the OP mentions bubbling...) |
As discussed here, we should apply the event blocking behavior for disablerd form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae
As discussed here, we should apply the event blocking behavior for disablerd form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae
As discussed here, we should apply the event blocking behavior for disablerd form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae
As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae
As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838}
As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838}
As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838}
https://bugs.webkit.org/show_bug.cgi?id=265071 rdar://problem/118584431 Reviewed by Tim Nguyen. This patch extends to not fire double click events on disabled elements similar to click event aligning with Gecko / Firefox, Blink / Chromium and agreed behavior in web specification issue [1]: [1] whatwg/html#2368 (comment) * Source/WebCore/dom/EventDispatcher.cpp: (EventDispatcher::dispatchEvent): * LayoutTests/imported/w3c/web-platform-tests/html/semantics/disabled-elements/disabled-event-dispatch.tentative-expected.txt: Rebaselined * LayoutTests/platform/ios-simulator-16-wk2/imported/w3c/web-platform-tests/html/semantics/disabled-elements/disabled-event-dispatch.tentative-expected.txt: Rebaselined * LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/semantics/disabled-elements/disabled-event-dispatch.tentative-expected.txt: Rebaselined Canonical link: https://commits.webkit.org/270951@main
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarhar@chromium.org> Reviewed-by: Mason Freed <masonf@chromium.org> Cr-Commit-Position: refs/heads/main@{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarharchromium.org> Reviewed-by: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976 UltraBlame original commit: 3bf4c6228d9c37fc63955610b37cb0bf6d5dff3d
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarharchromium.org> Reviewed-by: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976 UltraBlame original commit: 3bf4c6228d9c37fc63955610b37cb0bf6d5dff3d
…trol elements, a=testonly Automatic update from web-platform-tests Don't fire dblclick on disabled form control elements As discussed here, we should apply the event blocking behavior for disabled form controls to dblclick in addition to click, mouseup, and mousedown: whatwg/html#2368 (comment) Change-Id: Ibc52585ce0704d8ba8467efc3462bd378d23fbae Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5007308 Commit-Queue: Joey Arhar <jarharchromium.org> Reviewed-by: Mason Freed <masonfchromium.org> Cr-Commit-Position: refs/heads/main{#1225838} -- wpt-commits: dd5d55c3debd577a09921b32f3816797664c5e86 wpt-pr: 42976 UltraBlame original commit: 3bf4c6228d9c37fc63955610b37cb0bf6d5dff3d
https://wpt.fyi/results/html/semantics/disabled-elements/disabled-event-dispatch-additional.tentative.html?label=master&label=experimental&aligned The -additional test somehow expect different behavior between dblclick and auxclick, should they be consistent? |
I added auxclick to that test just to test the behavior at the request of my code reviewer. |
Gecko doesn't fire contextmenu either, although it's an allowlist instead of denylist in Gecko, so anything not in that list is blocked. (See #2368 (comment)) I have no strong opinion, I don't think contextmenu and auxclick is about activation, so I don't see any reason to block them. |
Not sure that my point is related to this topic, but I found this behaviour: Event "dblclick" and "contextmenu" are fired for disabled button in Google Chrome. All tests on MacOS. |
Are there any simple workarounds for |
displaying a hint, via tooltip, to describe why a control is disabled is something people are doing - but it's an antipattern that doesn't account for the fact that if the control is disabled, then someone using keyboard wont' be able to focus the control / reveal this tooltip. Unfortunately, the only workaround I would suggest is a design that is more inclusive, and doesnt' assume that all users can hover over the disabled control. |
dblclick is blocked in chromium, which includes chrome and edge. I implemented this due to feedback in this thread: #2368 (comment)
mouseenter should work on disabled form controls. it is fired in chrome based on my testing: https://jsfiddle.net/jarhar/652yamct/4/
+1 to making websites accessible |
Test: http://jsbin.com/botohet/edit?js,output
https://html.spec.whatwg.org/multipage/forms.html#enabling-and-disabling-form-controls:-the-disabled-attribute says:
I guess this is weird legacy behaviour, as it completely prevents the event, rather than stopping propagation during the bubbling phase.
Currently Chrome, Edge & Safari apply the same behaviour to all mouse events. I'd much prefer that all browsers switched Firefox's behaviour, but if it's too late to do this, the weird behaviour should probably become part of the spec.
Unfortunately Chrome & Edge do the same for pointer events, but hopefully that can be changed w3c/pointerevents#177.This was fixed for pointer events.The text was updated successfully, but these errors were encountered: