Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

Revisit Button Group HTML #3264

Open
kwinters opened this issue Feb 6, 2015 · 7 comments
Open

Revisit Button Group HTML #3264

kwinters opened this issue Feb 6, 2015 · 7 comments

Comments

@kwinters
Copy link

kwinters commented Feb 6, 2015

In 7727341 the button group code was changed from buttons to labels, Closes #1323. Closes #1482

But I think it's time to revisit that decision (2013).

http://getbootstrap.com/javascript/#buttons-checkbox-radio uses a label and an input, and none of the examples in http://getbootstrap.com/components/#btn-groups have labels at all.

The above commit's message is "Align with BS3 markup." but the code does not meet that goal, at least anymore. From the other threads, it looks like the example started with the input + label format and then determined that the inputs were not required, ending up with just label. However it appears that the typical usage is to use either actual buttons or divs, not orphaned labels.

And I think that the use of labels in this way should be discouraged in general. Labels tend to have styling associated with them that are not appropriate for an element that acts like a button.

@rvanbaalen
Copy link
Contributor

@kwinters I think you have a totally valid point there. @chrisirhc Any idea why the buttons where changed to labels back then?

If the labels would contain a checkbox/radio input it would make sense but they don't.

Btw; we're looking into full Bootstrap compatibility for milestone 0.14.0.

@rvanbaalen rvanbaalen modified the milestones: 0.14, Backlog Apr 8, 2015
@chrisirhc
Copy link
Contributor

This refers to the demo site's code. We can improve on this by including the input checkboxes but state in that they're not required. As it's a lot more code but it's good for accessibility.

Edit: See below.

@rvanbaalen
Copy link
Contributor

After digging in and checking bootstrap's source I would say for semantical and accessibility reasons we should add an <input> inside the <label> tag.

But, after I checked out Bootstrap's CSS I noticed that they target the internal <input> element with a css selector prefix:

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

So either we have to add data-toggle="buttons" to the wrapping div or we have to handle the hiding of the checkbox / radio button ourselves within the directive.

@chrisirhc beat me to it.

@rvanbaalen
Copy link
Contributor

I would say adding [data-toggle="buttons"] adds no added value to our templates and could possibly result in unwanted behavior. My vote goes to hiding the <input> ourselves within the btnCheckbox directive.

@chrisirhc
Copy link
Contributor

I see, that sounds reasonable. If a btn-checkbox element contains any input elements within, hide them. Encourages better accessibility code. However, take note of the notes written around the styles: https://github.com/twbs/bootstrap/blob/master/less/button-groups.less#L221-L243

// In order to support the browser's form validation feedback, powered by the
// required attribute, we have to "hide" the inputs via clip. We cannot use
// display: none; or visibility: hidden; as that also hides the popover.
// Simply visually hiding the inputs via opacity would leave them clickable in
// certain cases which is prevented by using clip and pointer-events.
// This way, we ensure a DOM element is visible to position the popover from.

So we might want to use the same styles.

@rvanbaalen
Copy link
Contributor

Good point! I'll take care of this after 0.13 is out.

@wesleycho wesleycho modified the milestones: 1.1.2, 1.1.1 Jan 25, 2016
@wesleycho wesleycho modified the milestones: 1.1.2, 1.2.0 Feb 1, 2016
@wesleycho wesleycho modified the milestones: 1.2.0, 1.2.1, 1.2.2, 1.3.0 Feb 26, 2016
@wesleycho wesleycho modified the milestones: 1.3.0, 1.3.1, 1.3.2, Backlog Apr 5, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants