Problem/Motivation
A single checkbox element inside a flexbox layout is visually broken.
Steps to reproduce
- Create a webform.
- Add a "layout" (flexbox container).
- Create a single checkbox field inside the flexbox container.
- Create any other kind of field inside the flexbox container.
- View the page at a viewport that is larger than 768px
The basic problem, is that the CSS that targets "inputs" should not target single checkbox inputs.
/* from webform.element.flexbox.css */
.webform-flex--container > .form-item > input,
.webform-flex--container > .form-item > select {
width: 100%;
}
Proposed resolution
There might be a couple approaches to solve this.
Option 1: CSS
Look at ways to exclude checkboxes from the css rules that set widths in: webform.element.flexbox.css Eg
.webform-flex--container > .form-item > input:not(.form-checkbox),
.webform-flex--container > .form-item > select {
width: 100%;
}
/* There are several other CSS rules that would need fixing, as well */
Option 2: Change the DOM Structure
Because the CSS uses the direct descended selector, we can maybe add another div wrapper around the .form-item class for single checkboxes, to avoid a css rule match.
Remaining tasks
Discuss pros/cons.
Write patch.
User interface changes
Display/layout bug will be fixed.
API changes
If option 2 is selected, HTML Dom structure produced by Webforms would be modified. Option 1 would produce no API changes I think.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#5 | 3177855-5.patch | 2.54 KB | jrockowitz |
#3 | Screen Shot 2020-10-20 at 11.30.41 AM.png | 25.85 KB | jwilson3 |
#3 | 3177855-3.patch | 2.52 KB | jwilson3 |
webform-flexbox-checkbox.gif | 129.8 KB | jwilson3 |
Comments
Comment #2
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedOption 1 makes sense to me and should also be applied to 8.x-5.x.
Comment #3
jwilson3Since there were several changes here related to prefix and suffix, I've tested visually what each one does in a flexbox layout, and I think this is probably the correct behavior.
Regarding this change:
This was really the only doubtful change, since this line is intended to UNSET the width from a previous rule, it could be argued that it isnt necessary, PLUS the question of whether a container inline is even possible with a single checkbox field — I doubt it, but anyway, I decided in favor of making the CSS rules consistent. You might have another take on this though which is fine.
Comment #4
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI think using
input:not([type="checkbox"])
is a little more specific and works with themes that do not implement the .form-checkbox class. Also, I think the patch should be also be applied to 8.x-5.x and 6.xComment #5
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedI think using
input:not([type="checkbox"])
is a little more specific and works with themes that do not implement the .form-checkbox class. Also, I think the patch should be also be applied to 8.x-5.x and 6.xComment #6
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commentedComment #7
jwilson3Totally makes sense. Duh.
Comment #9
jrockowitz CreditAttribution: jrockowitz as a volunteer and at The Big Blue House commented