Page MenuHomePhabricator

Download PDF element in toggle list should not set `type=button`
Closed, DeclinedPublic2 Estimated Story Points

Description

Currently, elements in overflow menu toggle list are buttons, which are

  • not catered to be perfectly cross-browser rendered (see missing min-height on last item

image.png (682×1 px, 147 KB)

  • carrying unnecessary type="button" attribute

Developer notes

The problem lies in the Icon code:
https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/master/src/mobile.startup/Icon.js#L128

This should only be set when the tag name is "input".

Event Timeline

Volker_E renamed this task from Elements in toggle list set to button? to Download PDF element in toggle list set to button?.Apr 15 2020, 9:44 PM
Jdlrobson triaged this task as Medium priority.Mar 3 2021, 9:51 PM
Jdlrobson added a project: patch-welcome.
Jdlrobson renamed this task from Download PDF element in toggle list set to button? to Download PDF element in toggle list should not set type=button.Aug 18 2021, 7:41 PM
Jdlrobson renamed this task from Download PDF element in toggle list should not set type=button to [a11y] Download PDF element in toggle list should not set type=button.
Jdlrobson updated the task description. (Show Details)
Volker_E renamed this task from [a11y] Download PDF element in toggle list should not set type=button to Download PDF element in toggle list should not set `type=button`.Aug 20 2021, 8:25 PM
Volker_E removed a project: Accessibility.

Change 716062 had a related patch set uploaded (by Nray; author: Nray):

[mediawiki/extensions/MobileFrontend@master] Remote type=\"button\" attribute from buttons

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

@Volker_E Can you expound on why the type is problematic?

Above is a patch that would remove the type attribute from the buttons unless explicitly passed a type, but I'd like to make sure this is really what we want.

First, adding an explicit type="button" attribute to the button element is valid and becomes critical to prevent bugs like T136243 because button elements within a form element act to submit the form by default. By adding the type="button" attribute, it makes it clear that the button does nothing by default regardless of where it is in the DOM unless JS adds a listener to it. Because of that clarity, numerous sources actually encourage adding it [1][2][3]. Popular component frameworks like MaterialUI [4], and Vuetify [5] both add the attribute to their button component and bootstrap seems to suggest [6] adding it as well.

Therefore, I'm wondering how problematic this is?

[1] https://www.w3schools.com/tags/att_button_type.asp
[2] https://html.com/attributes/button-type/
[3] https://medium.com/@clairecodes/why-its-important-to-give-your-html-button-a-type-193b4226fa0a
[4] https://material-ui.com/components/buttons/
[5] https://vuetifyjs.com/en/components/buttons/
[6] https://getbootstrap.com/docs/5.0/components/buttons/

Had to laugh that you were starting with w3schools, feel like I got trolled. :D
I honestly read about submit being the default on button element (over type=button) the last time probably 7 years ago. Thanks for digging carefully deeper @nray. We might be better off declining this task.

Change 716062 abandoned by Jdlrobson:

[mediawiki/extensions/MobileFrontend@master] Remote type=\"button\" attribute from buttons

Reason:

Per https://phabricator.wikimedia.org/T250324#7350808

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