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

Toggle style checkboxes initialized with JS don't work #2572

Closed
malacalypse opened this issue Jul 9, 2015 · 5 comments
Closed

Toggle style checkboxes initialized with JS don't work #2572

malacalypse opened this issue Jul 9, 2015 · 5 comments

Comments

@malacalypse
Copy link
Contributor

https://jsfiddle.net/pwkayddm/2/

.ui.toggle.checkboxes don't work when initialized with .checkbox() anymore.

I've included both a rails-style checkbox (two inputs - one hidden, one a checkbox) and a traditional single-element checkbox, both written in the traditional inline style used by simple_form among many other libraries.

These used to work just fine in Semantic-UI 1.x , but now their toggle behaviour isn't correct - it appears to be double triggering. I thought it was simply because the onClick is bound to the label, which usually causes a double call on the input itself, but fixing that didn't entirely solve the problem.

@jlukic
Copy link
Member

jlukic commented Jul 9, 2015

If you remove the for attribute they will work correctly.
http://jsfiddle.net/cent6fgx/

It's causing it to double trigger. I'll see if I can't handle this in JS.

@jlukic jlukic added this to the 2.0.3 milestone Jul 9, 2015
@malacalypse
Copy link
Contributor Author

Hi Jlukic,

Thanks for the quick response.

The 'for' attribute is often (and in our case, definitely) required for accessibility reasons. Removing it breaks the link between the label and the input for screen readers and other accessibility assistive devices. It also breaks the fallback behaviour of the label triggering the input for touch devices - creating a larger target.

If there's a clean fix that doesn't break that link, it would be superior.

@jlukic
Copy link
Member

jlukic commented Jul 9, 2015

ui checkbox that are not initialized with js automatically link labels using an overlayed hidden input. This will still affect screenreaders though. I'll circle back for a different solution.

@malacalypse
Copy link
Contributor Author

Hi Jlukic,

After some considerable digging with a coworker, the answer seems quite simple.

Let me know if you have any comments.

malacalypse added a commit to bandzoogle/less-rails-semantic_ui that referenced this issue Jul 10, 2015
@jlukic
Copy link
Member

jlukic commented Jul 10, 2015

Fixed in commit

@jlukic jlukic closed this as completed Jul 10, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants