Skip to content
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

Update Button and Input Activation behaviours #11053

Merged
merged 6 commits into from
Feb 26, 2025

Conversation

lukewarlow
Copy link
Member

@lukewarlow lukewarlow commented Feb 20, 2025

Update Button and Input Activation behaviours

Reset buttons and inputs no longer trigger popover target activation behaviour when there's a form owner.

Reset buttons no longer trigger command button activation behaviour when there's a form owner.

Missing and invalid type buttons no longer trigger command button activation behaviour when there's a form owner.

(See WHATWG Working Mode: Changes for more details.)


/form-elements.html ( diff )
/input.html ( diff )

Reset buttons and inputs no longer trigger popover target activation behaviour.

Reset buttons no longer trigger
command button activation behaviour.
@lukewarlow
Copy link
Member Author

lukewarlow commented Feb 20, 2025

This PR introduces a 'breaking' change to popovertarget button behaviour that is intentional. Chrome never supported reset buttons/inputs for popovers and WebKit didn't on buttons but did on inputs (until recently when the buttons were fixed to work per spec).

When a button has a form owner (is inside form or has a valid form attribute).

A) Button has a missing type attribute.
B) Button has an invalid type attribute.
C) Button has a type="submit" attribute.
D) Button has a type="reset" attribute.
E) Button has a type="button" attribute.

F) Input has a type="submit" attribute.
G) Button has a type="reset" attribute.
H) Button has a type="button" attribute.
I) Button has a type="image" attribute.

Table of behaviour when popovertarget is on each of these buttons.

Before After
1.A Form Submission Form Submission
1.B Form Submission Form Submission
1.C Form Submission Form Submission
1.D Form Reset And Popover Toggled* Form Reset Only
1.E Popover Toggled Popover Toggled
1.F Form Submission Form Submission
1.G Form Reset And Popover Toggled* Form Reset Only
1.H Form Submission Form Submission
1.I Form Submission Form Submission
  • Chromium actually only resets the form in this case current.

Table of behaviour when command and commandfor is on each of these buttons (input cases N/A).

Before After
1.A Command Invoked No-Op
1.B Command Invoked*** No-Op
1.C Form Submission Form Submission
1.D Form Reset And Command Invoked Form Reset Only
1.E Command Invoked Command Invoked

*** Invalid type buttons originally were intended to behave as submit buttons and like type=submit, but the spec made them auto buttons like missing type buttons, based on discussions in whatnot this also seems to be desired behaviour.

@lukewarlow lukewarlow force-pushed the command-button-activation-changes branch from 9a01180 to 8bcbbf9 Compare February 20, 2025 11:24
Copy link
Member

@zcorpan zcorpan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this achieves the interim state described in #11044 (comment)

@lukewarlow lukewarlow requested a review from annevk February 25, 2025 16:36
@lukewarlow
Copy link
Member Author

@zcorpan can I mark this as supportive from Mozilla's side?

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@keithamus should double check this, but I don't think this needs separate implementer approvals as this was supposed to be part of the original PR.

@lukewarlow
Copy link
Member Author

ut I don't think this needs separate implementer approvals as this was supposed to be part of the original PR.

This does include a change to popovertarget which wasn't part of the original but came from discussions in whatnot, so that aspect might do?

@annevk annevk added the topic: popover The popover attribute and friends label Feb 25, 2025
@annevk
Copy link
Member

annevk commented Feb 25, 2025

Fair enough. You can consider WebKit interested. cc @nt1m

Copy link
Contributor

@keithamus keithamus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this puts us in a good state with the intent of the original PR. So +1 from me.

@zcorpan
Copy link
Member

zcorpan commented Feb 26, 2025

This is OK for Mozilla.

@annevk annevk merged commit ebbf54f into whatwg:main Feb 26, 2025
2 checks passed
@lukewarlow lukewarlow deleted the command-button-activation-changes branch February 26, 2025 14:29
aarongable pushed a commit to chromium/chromium that referenced this pull request Feb 27, 2025
This change does a few things to align with the latest spec, based on
the changes in whatwg/html#11053.

- Reset buttons should _only_ reset the form, not trigger additional
  popover or command behaviours.
- Buttons should reflect "button" when command/commandfor attributes
  are present, with or without a form-owner.
- Buttons that reflect "button" with command/commandfor attributes
  that have a form-owner should be no-op; this is a restriction for
  back-compat that will eventually be lifted.
  whatwg/html#10832 tracks the state of
  this, and consequently I've added a UseCounter to help figure out
  when it is safe to make this change.

Bug: 399124617
Change-Id: I684371bb7fc8e0888bcf0713caff212f4806a7c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6304979
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1425642}
WeizhongX added a commit to web-platform-tests/wpt that referenced this pull request Feb 27, 2025
This change does a few things to align with the latest spec, based on
the changes in whatwg/html#11053.

- Reset buttons should _only_ reset the form, not trigger additional
  popover or command behaviours.
- Buttons should reflect "button" when command/commandfor attributes
  are present, with or without a form-owner.
- Buttons that reflect "button" with command/commandfor attributes
  that have a form-owner should be no-op; this is a restriction for
  back-compat that will eventually be lifted.
  whatwg/html#10832 tracks the state of
  this, and consequently I've added a UseCounter to help figure out
  when it is safe to make this change.

Bug: 399124617
Change-Id: I684371bb7fc8e0888bcf0713caff212f4806a7c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6304979
Commit-Queue: Keith Cirkel <chromium@keithcirkel.co.uk>
Reviewed-by: Mason Freed <masonf@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1425642}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: popover The popover attribute and friends
Development

Successfully merging this pull request may close these issues.

4 participants