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

Add type="button" to the accordion toggler #6898

Merged
merged 1 commit into from Feb 16, 2024

Conversation

fritzmg
Copy link
Contributor

@fritzmg fritzmg commented Feb 15, 2024

If you happen to insert an accordion content element in a form, e.g. in an HTML code form field with the {{insert_content::*}} insert tag, the toggler of the accordion will currently submit the form when clicked, instead of just opening/closing the accordion.

This is because any <button> without a specific type will be treated as a type="submit" button by default: https://html.spec.whatwg.org/multipage/form-elements.html#the-button-element

The attribute's missing value default and invalid value default are both the Submit Button state.

Since our toggler button is not supposed to submit anything but rather just act "as a button", it needs type="button".

@fritzmg fritzmg added the bug label Feb 15, 2024
@fritzmg fritzmg added this to the 5.3 milestone Feb 15, 2024
@fritzmg fritzmg self-assigned this Feb 15, 2024
@leofeyer leofeyer changed the title Add type="button" to accordion toggler Add type="button" to the accordion toggler Feb 16, 2024
@leofeyer leofeyer merged commit c29e489 into contao:5.3 Feb 16, 2024
18 checks passed
@leofeyer
Copy link
Member

Thank you @fritzmg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants