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

Selecting the end of the range requires shift-clicking exactly the checkbox #7

Open
andrewmy opened this issue Jul 28, 2014 · 18 comments

Comments

@andrewmy
Copy link

At least in Firefox 32: shift-clicking the second checkbox label doesn't work.
Works in Chrome though.

@rmariuzzo
Copy link
Owner

Hey @andrewmy! Thanks for letting me know about that issue, I have just tried to reproduce using Firefox 30 on Fedora 19, and everything works as expected. However I'm upgrading Firefox to get version 32 and will try to reproduce it.

Did you tried the range selection with the demo at: http://rmariuzzo.github.io/checkboxes.js/#range-selection-of-checkboxes ?

@andrewmy
Copy link
Author

andrewmy commented Aug 4, 2014

Hey, thanks for reply. I tried the demo too, same: the second click has to happen on the checkbox. If it's on the label, it just selects the text between the items.
Observing it on Win 7, will look on a Mac later.

@rmariuzzo
Copy link
Owner

Thanks for providing more information, I will make sure to create some test cases when clicking on labels.

@rmariuzzo
Copy link
Owner

Investigating a little bit looks like this issue only occurs in Firefox. There's a bug reporter in their tracker: https://bugzilla.mozilla.org/show_bug.cgi?id=559506

Since that bug is present since version 3 of Firefox, I will think on a way to circumvent that issue in Firefox.

@rmariuzzo rmariuzzo added the bug label Aug 27, 2014
@iajrz
Copy link

iajrz commented Dec 9, 2014

Chrome 39 exhibits the same behavior.

@rmariuzzo
Copy link
Owner

We should address this issue ASAP.

@ramikassab
Copy link

@rmariuzzo I tried using your awesome plugin on a set of checkboxes in a div that have been turned into Bootstrap 3 buttons, which essentially hides the checkbox and makes the label look like a button with an inactive and active state like a checkbox would have. Unfortunately, at least in Chrome 39, I was unable to get range selection to work and I suspect that it may be due to this issue. Removing the data-toggle="buttons" from the containing div revealed the checkbox elements and, therefore, worked... but my buttons were messed up :(

Here's a screenshot of the Bootstrap 3 buttons I'm trying to use range selection on:
image

Would love to see a fix for this!

@rmariuzzo
Copy link
Owner

@ramikassab thanks for the feedback and detailed information, I will check on this right now.

I'm on the chat: https://gitter.im/rmariuzzo/checkboxes.js

@rmariuzzo
Copy link
Owner

@ramikassab I have made a simple test case for your scenario. I can see the issue you described. However, no feature from this plugin work well with Twitter Boostrap 3 checkbox/radio buttons. The main reason is that Twitter Boostrap 3 checkbox/radio buttons implementation doesn't listen to checkbox/radio change's events. Thus, there's no somehow-standard way to tell Twitter Boostrap 3 checkbox/radio buttons that underlying inputs got its value changed.

For now, I'm assuming that particular issue should be workarounded with event listeners... but I'm still unable to figure a way out. If you will need help on this scenario, let me know to dig deeper.

@johnpalaganas
Copy link

@rmariuzzo Any updates on being able to do range select by clicking on the label instead? Thanks!

@rmariuzzo
Copy link
Owner

@johnpalaganas I will invest ~1hr now to come with a fix to this. I'm thinking to cover those cases:

  1. When the label wraps the checkbox.
<label>
    <input type="checkbox" /> Apple
</label>
  1. When the label is associated to the checkbox via for attribute.
<input type="checkbox" id="apple" />
<label for="apple">Apple</label>

Any suggestions will be highly appreciated. 😄

@johnpalaganas
Copy link

@rmariuzzo If you can cover those two cases, it would be great! :)

@rmariuzzo
Copy link
Owner

Thanks for your quick reply @johnpalaganas! I will create a separate branch for this.

@rmariuzzo rmariuzzo self-assigned this Mar 18, 2015
@rmariuzzo rmariuzzo modified the milestone: 1.0.7 Mar 18, 2015
@johnpalaganas
Copy link

Well thanks @rmariuzzo for your proactive approach!

@rmariuzzo
Copy link
Owner

@johnpalaganas I have just added support to labels for range selection: https://github.com/rmariuzzo/checkboxes.js/tree/range-improvements

I have only tested it with Chrome 41, later today I will test in other browsers.

I have created added a quick test to play around, but somehow it doesn't behave as my local environment: http://plnkr.co/edit/iPIep0cWO5SAxGoTQ4Ng

I need to fix this.

@johnpalaganas
Copy link

@rmariuzzo Thanks! Not working on my end, I hope you do find a solution :)

@rmariuzzo
Copy link
Owner

I'm here again trying to find a definitive solution to this issue. It has been a long time.

@m1dst
Copy link

m1dst commented Dec 16, 2015

The version in the test branch seems to work for me where I hide the checkbox and style the label and use the FOR property to associate them. Just tested in FF42, Edge and CH47. Great job.

I caveat this with 2 small changes to make it suit my situation. I am toggling a class to TR when each checkbox is checked. Out of the box the plugin is not firing the change event of the checkboxes so I manually trigger it. Not sure if it is the best approach but it works for me.

// Toggle checked property of the related checkbox.
if ($checkbox && !$checkbox.is(':disabled')) {
      $checkbox.prop('checked', !$checkbox.prop('checked'));
      $checkbox.trigger("change");     // I added this line
}

$checkboxes.slice(start, end)
      .filter(':not(:disabled)')
      .prop('checked', $checkbox.prop('checked'))
      .trigger("change");         // I added this line too

@rmariuzzo rmariuzzo removed this from the 1.1.0 milestone Jul 31, 2016
@rmariuzzo rmariuzzo modified the milestones: 1.2.0, 1.1.0 Jul 31, 2016
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

6 participants