Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate .btn-group-toggle class for simpler selectors #25281

Closed
hafezd opened this issue Jan 12, 2018 · 4 comments
Closed

Deprecate .btn-group-toggle class for simpler selectors #25281

hafezd opened this issue Jan 12, 2018 · 4 comments
Assignees
Labels

Comments

@hafezd
Copy link

hafezd commented Jan 12, 2018

Single toggle button used to work with checkbox/radio buttons on 4.0.0-beta.2 like this:

<div data-toggle="buttons">
  <label class="btn btn-outline-primary">
    <input type="checkbox" autocomplete="off"> I don't know
  </label>
</div>

Output:
image

But it doesn't work anymore on 4.0.0-beta.3:
image

I searched your change log and found #23728 but It doesn't make sense to add btn-group-toggle to a single toggle button to make this work.

@mdo
Copy link
Member

mdo commented Jan 12, 2018

Yeah, we have to improve the naming there, but we were working with what we had in our betas. For now, use the class. Our motivation for the change was separating style from behavior. In the future, we won't need this separation because we'll rewrite the component to use sibling selectors and leverage all the browser behaviors we have from inputs.

@mdo mdo closed this as completed Jan 12, 2018
@hafezd
Copy link
Author

hafezd commented Jan 12, 2018

@mdo the current selector for hiding checkbox/radio button in a toggle button is like this:

.btn-group-toggle > .btn input[type="radio"],
.btn-group-toggle > .btn input[type="checkbox"],
.btn-group-toggle > .btn-group > .btn input[type="radio"],
.btn-group-toggle > .btn-group > .btn input[type="checkbox"] {
    position: absolute;
    clip: rect(0, 0, 0, 0);
    pointer-events: none;
}

Why not just:

label.btn input[type="radio"],
label.btn input[type="checkbox"] {
    ...
}

Hide checkbox if it was in a button, it works for both single and group toggle buttons:

<label class="btn btn-outline-primary">
    <input type="checkbox" autocomplete="off"> I don't know
</label>

@mdo
Copy link
Member

mdo commented Jan 13, 2018

Hmm, something like that could be doable. We try to avoid qualified selectors like that, but I'm wondering if we just always do that for inputs in buttons. Semantically there's no value to putting inputs in <a> or <button> elements, so could work without label in front.

@mdo mdo reopened this Jan 13, 2018
@mdo mdo changed the title Single toggle button with checkbox/radio buttons Deprecate .btn-group-toggle class for simpler selectors Jan 13, 2018
@mdo
Copy link
Member

mdo commented Dec 17, 2018

Punting the changes here to #25185, which I hope to include in v5 alongside dropping of the existing component.

@mdo mdo closed this as completed Dec 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants