question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent checkbox placement when a hidden element is between a legend and .form-check

See original GitHub issue
  • Operating system: macOS 10.15.6
  • Browser: Chrome 84.0.4147.105

In the alpha for 5.0.0 when a legend is followed by a hidden element (tested with .d-none and input[type="hidden"]) and div.form-check, then the checkbox will be on the same line as the legend but not the label, and also makes the checkbox not clickable (though it’s possible to check by focusing on it). This seems to be the case with normal checkboxes and switches.

Example problematic markup:

<form>
  <fieldset>
    <legend>Unexpected</legend>

    <p class="d-none">Hello</p>
    <div class="form-check">
      <input class="form-check-input" type="checkbox" id="foo">
      <label class="form-check-label" for="foo">Foo</label>
    </div>
  </fieldset>
</form>

Produces this

Screen Shot 2020-08-12 at 3 34 40 PM

I would expect it to lay out like this (and also be clickable)

Screen Shot 2020-08-12 at 3 35 33 PM

Code Pen https://codepen.io/tegandbiscuits/pen/poygjPE

The current behavior is also not what happens with checkboxes in Bootstrap 4.

Also this seems to be able to be resolved by wrapping both the hidden element and .form-check in a div.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mdocommented, Sep 18, 2020

Thinking about this specific example again, you might just want to add a good ol’ fashioned <div class="clearfix"></div> before the hidden element. That’ll fix the issue.

1reaction
ffooddcommented, Aug 20, 2020

Tried something using display: contents but then realized support is pretty bad and buggy

There might be a better way using grid or something, not sure yet.

TBH, I’d be in favor of dropping float: left here, since our standard build does not need it —no borders on fieldset— and it can be easily managed using .float-left utility (which would then be opt-in).

The better way around IMHO would be to add clear utilities.

Read more comments on GitHub >

github_iconTop Results From Across the Web

H71: Providing a description for groups of form controls ... - W3C
The first element inside the fieldset must be a legend element, which provides a label or description for the group. Authors should avoid...
Read more >
jQuery Plugin Development Beginner's Guide
movement and events, positioning through CSS rules, and, last but not least, interaction with jQuery code to actually show and hide the tooltip...
Read more >
Help with hiding/unhiding -Check box 1 is checked
I have a form that will toggle multiple checkboxes hiding and unhiding ... then if checkbox 2 is checked Hide checkbox 1 and...
Read more >
Amcharts - Checkbox legend - Stack Overflow
legendData ; var div = $("<div style='position:absolute; ... legendEntry.y + "px' " + "type='checkbox'" + (legend[i].hidden ?
Read more >
legend.itemCheckboxStyle | highstock API Reference
The legend is a box containing a symbol and name for each series item or point item in ... The horizontal alignment of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found