Closed Bug 1991743 Opened 7 months ago Closed 6 months ago

Inherit "form" attribute into moz- input elements when set

Categories

(Toolkit :: UI Widgets, enhancement)

Desktop
All
enhancement

Tracking

()

RESOLVED FIXED
147 Branch
Tracking Status
firefox147 --- fixed

People

(Reporter: Gijs, Assigned: tgiles)

References

(Blocks 1 open bug)

Details

(Whiteboard: [recomp])

Attachments

(3 files)

Folks want to use moz-checkbox and moz-radio-group and such with HTML <form> elements and sometimes that requires using a form attribute (if the input isn't a descendant of the relevant form element). But the attribute needs to be on the actual <input> and so the custom element should ideally forward the one set on the custom element to the nested <input>.

See https://phabricator.services.mozilla.com/D265895#inline-1456964 where I originally tried to suggest we use moz-checkbox, only we can't...

See Also: → 1987781
Whiteboard: [recomp]

I'm hoping this is as straightforward as adding the static formAssociated = true; to the various base input elements we have. If not, I'll write up my findings so we can figure out how to best solve this.

Assignee: nobody → tgiles
Status: NEW → ASSIGNED
Type: defect → enhancement
Severity: -- → N/A

By utilizing the static formAssociated property, we allow elements
that extend the MozBaseInputElement to work as expected when used in
form elements. Since we are changing the base input element to be a
form-associated element, we have to implement some additional functions
that are common to form elements. These are the form() getter, the
public setFormValue method, and the public formResetCallback method.

The setFormValue is a public method because we need subclasses of the
base input element to be able to modify the private internals of the
base input class.

We need to override the public setFormValue and formResetCallback
methods of the base input element for moz-checkbox to behave as expected
in forms.

In order for moz-radio-group to behave correctly when used in a form, we
needed to add the formAssociated property to the SelectControl class
and implement setFormValue and formResetCallback.

Blocks: 1996125
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/19837b0f8aa1 https://hg.mozilla.org/integration/autoland/rev/c88b8be3d2b3 Revert "Bug 1991743 - Add form behavior for SelectControl. r=mkennedy" for causing mochitests failures in test_moz_checkbox.html.

Reverted this because it was causing mochitests failures in test_moz_checkbox.html.

  • Revert link
  • Push with failures
  • Failure Log
  • Failure line: TEST-UNEXPECTED-FAIL | toolkit/content/tests/widgets/test_moz_checkbox.html | The nested moz-checkbox element is enabled when the parent input is activated. - got true, expected false

Please also check this failure.

Flags: needinfo?(tgiles)

Fixed the test failures and queued up a new landing. We'll see if it sticks this time.

Flags: needinfo?(tgiles)
Status: ASSIGNED → RESOLVED
Closed: 6 months ago
Resolution: --- → FIXED
Target Milestone: --- → 147 Branch
QA Whiteboard: [qa-triage-done-c148/b147]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: