Page MenuHomePhabricator

HTMLForm renders an unnecessary label element for elements without a label
Closed, ResolvedPublic


This isn't a big problem for a div/table/raw output, as the element is "simply there" (even if it would be cleaner to not have this element at all, if it's not needed, and it isn't), but it's a bigger problem for OOUI forms. Look at the following (where the submit button is created as an element (and the default submit button is omitted):

Without JavaScript
without_js.PNG (297×841 px, 10 KB)
The label creates an unnecessary gap between the input and the button
With JavaScript
with_js.PNG (284×932 px, 11 KB)
The label is removed when rebuilding (~infusing) the form

If the connection is slow, the user also notices a visible rebuilding of the form, which isn't really great. As a solution, HTMLForm should simply omit the label field, if it's no label is specified. We already had something similar, where unneded elements are visible in OOUI only: T117768: OOUIHTMLForm wraps Hidden fields into a fieldset.

Event Timeline

Change 277177 had a related patch set uploaded (by Florianschmidtwelzow):
Don't add label-elements for elements that doesn't have one

Hmm, if the display of an element changes after it is infuses, that's also a bug.

Florian triaged this task as Medium priority.Mar 14 2016, 1:35 AM

Change 277177 merged by jenkins-bot:
Don't add label-elements for elements that doesn't have one