I noticed this behavior in Special:NewLexeme (cc T370052), but can also reproduce it in a playground: If you have a <cdx-button type="submit"> inside a <form>, and the form has a submit handler, then clicking the button with the mouse will run the submit handler (as expected), but focusing it and then pressing Enter or Space will not. (Tested in Firefox 131 and Chromium 129.)
Description
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Update Codex from v1.13.1 to v1.14.0 | mediawiki/core | master | +574 -144 | |
Button: trigger actual click on key interaction | design/codex | main | +7 -2 |
Related Objects
Event Timeline
Hey @Lucas_Werkmeister_WMDE, thanks for reporting this. We'll pick it up at the next opportunity, probably next sprint.
@Lucas_Werkmeister_WMDE looks like this is an unintended consequence of something we did a while back to fix inconsistencies between Enter and Space keypress events here: https://gerrit.wikimedia.org/r/c/design/codex/+/1053023.
We'll pick this up soon.
Alright, thanks! For the record, we’ve worked around this issue in the meantime by moving the event handler to the button itself – as far as I can tell, there was no strong reason to have it on the form (though it was slightly more convenient for the tests that way, as you can see in the diff of the workaround).
Change #1078753 had a related patch set uploaded (by Anne Tomasevich; author: Anne Tomasevich):
[design/codex@main] Button: trigger actual click on key interaction
We need to do the following:
- Make sure clicking, pressing enter, and pressing space all result in the same behavior
- Make sure you don't emit multiple click events or form submissions if you hold down a key
What if, instead of emitting a click even on keyup, we trigger an actual button click? See my patch as a proof of concept.
Change #1078753 merged by jenkins-bot:
[design/codex@main] Button: trigger actual click on key interaction
Re-opening and moving to the sprint board because we usually close these after the release goes out.
Change #1080747 had a related patch set uploaded (by LWatson; author: LWatson):
[mediawiki/core@master] Update Codex from v1.13.1 to v1.14.0
Test wiki created on Patch demo by LWatson-WMF using patch(es) linked to this task:
http://patchdemo.wmcloud.org/wikis/ff2c211f43/wiki/Main Page
Change #1080747 merged by jenkins-bot:
[mediawiki/core@master] Update Codex from v1.13.1 to v1.14.0