Page MenuHomePhabricator

Codex submit button does not submit associated form when activated using keyboard
Closed, ResolvedPublic1 Estimated Story PointsBUG REPORT

Description

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.)

Event Timeline

CCiufo-WMF changed the subtype of this task from "Task" to "Bug Report".
CCiufo-WMF moved this task from Inbox to Needs Refinement on the Design-System-Team board.
CCiufo-WMF subscribed.

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

https://gerrit.wikimedia.org/r/1078753

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

https://gerrit.wikimedia.org/r/1078753

CCiufo-WMF assigned this task to AnneT.
CCiufo-WMF set the point value for this task to 1.

Re-opening and moving to the sprint board because we usually close these after the release goes out.

Lucas_Werkmeister_WMDE changed the task status from Open to In Progress.Oct 11 2024, 8:26 AM

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

https://gerrit.wikimedia.org/r/1080747

Looks good to me when comparing 1.13.1 with 1.14.0 \o/

nice, thanks for confirming @Lucas_Werkmeister_WMDE!

Change #1080747 merged by jenkins-bot:

[mediawiki/core@master] Update Codex from v1.13.1 to v1.14.0

https://gerrit.wikimedia.org/r/1080747