Closed Bug 1487102 Opened 7 years ago Closed 3 years ago

Space Bar pressing on radio-button fires click event even preventDefault() and stopPropogation() activated

Categories

(Core :: DOM: Core & HTML, defect, P3)

defect

Tracking

()

RESOLVED WORKSFORME
Tracking Status
firefox61 --- affected
firefox62 --- affected
firefox63 --- affected

People

(Reporter: Xgeneration, Unassigned)

References

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36 Steps to reproduce: I'am trying to activate\deactivate radio button by Space Bar key pressed. To achieve this behavior I'am tried to subscribe to keydown event, activate\deactivate radio buttons and prevent default logic for keydown event. <html> <body> <p>How would you like your coffee?</p> <input id="should-be-a-button" type="radio" name="coffee" value="cream">With cream<br> <script> onDOMContentLoaded = (function(){ var element = document.querySelector('#should-be-a-button'); element.addEventListener('click', function(){console.log('click');}, false); element.addEventListener('keydown', function(event) { if (event.keyCode === 13 || event.keyCode === 32) { console.log('keydown') event.preventDefault(); } }, false); })() </script> </body> </html> Actual results: But as I can see keydown on radio button fires click event on radio-button. Expected results: Click event on radio-button not firing if preventDefault activated
I'am not sure if click event should be called at all
I managed to reproduce the issue on Windows 10, Ubuntu 16.04 and Mac OS, on Nightly 63.0a1 (2018-09-02), Firefox 61.0.2 and Firefox 62.0.
Status: UNCONFIRMED → NEW
Component: Untriaged → Event Handling
Ever confirmed: true
OS: Unspecified → All
Product: Firefox → Core
Hardware: Unspecified → All
Version: 61 Branch → Trunk
Click event from space bar sounds like an accessibility thing. Olli, do you have any thoughts on this?
Flags: needinfo?(bugs)
Ancient behavior from Netscape era. Not really a11y, just basic keyboard usage.
Component: Event Handling → User events and focus handling
Priority: -- → P3
Component: User events and focus handling → DOM: Core & HTML
Flags: needinfo?(bugs)

Hi!

I'm just popping in to confirm I see this issue in FF 96.0.3 when trying to use event.preventDefault() on a button element. I'm unable to prevent the click when it's triggered with a space bar. Preventing it when triggered via Enter works as expected.

Seems as though this ticket is very old. Is there any hopes in reviving this and getting a fix in?

Thanks!

(In reply to kee-oth from comment #6)

I'm just popping in to confirm I see this issue in FF 96.0.3 when trying to use event.preventDefault() on a button element. I'm unable to prevent the click when it's triggered with a space bar. Preventing it when triggered via Enter works as expected.

That seems like a different issue from comment 0. Comment 0 seems fixed, or at least I can't activate the checkbox with spacebar or enter in comment 7 (on Nightly at least).

Can you attach a test-case for what you're seeing? Comment 9 seems to behave as expected here too, on Nightly.

Flags: needinfo?(dpra)

Thank you for the quick reply! Your test case works for me and I'm unable to recreate my issue in smaller test-cases at the moment. I'm only experiencing it in my more complex project so some other tech may be the culprit. I will report back if I'm able to recreate the issue in a test-case that points to Firefox.

And regarding if this was the correct ticket to post on or not, I posted here because the below ticket was marked as a duplicate of this one:
https://bugzilla.mozilla.org/show_bug.cgi?id=1552419

Thanks again!

Flags: needinfo?(dpra)

(In reply to kee-oth from comment #11)

Thank you for the quick reply! Your test case works for me and I'm unable to recreate my issue in smaller test-cases at the moment. I'm only experiencing it in my more complex project so some other tech may be the culprit. I will report back if I'm able to recreate the issue in a test-case that points to Firefox.

And regarding if this was the correct ticket to post on or not, I posted here because the below ticket was marked as a duplicate of this one:
https://bugzilla.mozilla.org/show_bug.cgi?id=1552419

Ok, comment 0 and the test-case in bug 1552419 seem fixed here. If someone wants to run mozregression to see what exactly fixed it that'd be great, but let's call this WORKSFORME for now.

If you manage to reproduce the issue in a test-case and it is a firefox issue feel free to file a new bug and cc me, happy to take a look :)

Cheers.

Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: