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
Button: Fixed #7665 - Radio button & checkboxes ignore mouseclicks for minor mouse movements #854
Conversation
…tton: Radio button & checkboxes ignore mouseclicks for minor mouse movements
Thanks again, @UltCombo! For future reference, can you please use topic branches when submitting pull requests? It'll be easier to rebase if necessary. As far as this PR goes, please use the conditional for oldIE in the unit tests, but please ensure it all still works as expected. It also has indentation issues, in that the comments need to be intended to the same level as the code block. Furthermore, it seems like more testing is in order for this. What do you think? it seems like one test for such a change is inadequate. Thoughts? |
Oh thanks, I'll start branching for future PRs. I'll fix the indentation ASAP. As for the tests, I'm not entirely sure what kind of tests are the most necessary. I was about to make a full-fledged radio buttons behavior test, then I noticed the I just noticed that some of my code removal may bug in old IE when calling |
@UltCombo, since you noticed the bug, add a test for that as well. That's the approach here. Try to attack the changes you made to make sure they don't introduce any regressions, and so that future changes won't introduce any either. |
@mikesherov Understood. There's some other cross-browser inconsistencies in the tests as well. More namely, when calling
I find it unlikely for developers to call
I'm considering another workaround, using a delayed refresh to ensure that old IE has the correct display after calling |
I wouldn't want to land any changes that weren't first fixed in core if there's a core bug at the heart of this. The guy who really knows the horror that is browser events is @dmethvin. Perhaps we can leverage his expertise here if there's a workaround to be had? |
Well, this core bug seems very minor and only affects unit tests in old IE. Of course, if @dmethvin will have free time to lend us a hand, it'd be great. The only problem is with Meanwhile, I'll update the unit tests to reflect that. |
Added a couple tests, all tests now pass in all supported browsers including IE6-8 and Safari. Only issue is that programmatically calling a label's IMO triggering a click event on a label and expecting the input to toggle itself and fire the change event including old browsers is asking too much and would be set to invalid if reported on the bug tracker, this is mostly a test-only scenario. A sturdy cross-browser way to do this in a production site is to set the checked property followed by triggering the change handlers:
That's the correct approach that will never fail in any browser and should be adopted over expecting a checkbox to magically toggle itself and trigger its change event by dispatching a synthetic event to a label element. The latter would be just encouraging bad practices IMHO. |
I can standardize triggered click on label elements cross-browser by either using another timeout and a change check or propose it to the core by adding 2 flags to IMO it is unnecessary and mostly just encourages bad practices, but I can add it in order to don't generate back-compat issues if needed. |
@UltCombo, thanks again for the detective work here. I'll be reviewing this a bit more fully this weekend. |
Alright, I'll add a couple more tests later today. |
…-browser issues with calling .click() on labels; fixed tests
@mikesherov Just did another makeover on the Button code. Calling |
Concluded standardizing the button labels' |
Please remove all commented out code lines. They don't need to be there :-) |
My bad, kept them while testing and ended up leaving it there before committing. Removed now. |
The only issue that I see with my fix's code above is that click handlers for the labels may not fire for long drags while still toggling the checkbox's Maybe utilizing a real button inside the label as in http://jsfiddle.net/2nLqb/1/ could be a better solution as buttons allow for long drags naturally, discarding the |
@UltCombo, thanks again for the work here. Seeing as this got a lot larger, I'm going to wait till after 1.10 is out to land this, as it needs heavy testing. Thanks again! |
No problem, you're welcome. The only issue that still stands is the label's click handlers not firing for long drag clicks while the |
I'm using your http://ultcombo.github.com/UltButtons/ plugin UltCombo. I'm also using Knockout.js to bind to a simple radio button array using the checked binding. http://knockoutjs.com/documentation/checked-binding.html When I click normally without moving at all then the datamodel is updated. If I click and drag then it's not. |
@teknohippy This in not an appropriate place to ask for help with 3rd party plugins. |
@teknohippy open an issue in the appropriate repo please, and while you're at it provide a test case there so we can solve it. |
@scottgonzalez The issue reported by tekno may be related to this PR as well though. Although jQuery has no compromise to work with other libraries, with this PR's code the Button widget will no longer trigger natively attached listeners, meaning some people may be hesitant to upgrade afterwards. There's also one question left, shouldn't the button widget call Also, if this needs rebasing before landing, just comment and I'll update the code. |
|
I wasn't aware of that, thanks for the info. My next plugins will keep using their own version of |
@UltCombo, thanks for being so patient. I'm ready to review this code again. Can you rebase this pull request? |
Of course. Just when I was trying to decide what to do code for this weekend. |
@mikesherov Ok, I believe I did the rebasing correctly. If there's an issue in how I did the merge, just @ me and I'll start a new pull from a branch. |
That looks like you did @mikesherov probably more sane to just throw away that merge commit and do the rebase yourself? |
@jzaefferer There'll be more commits from review. I'd like to start from a rebased position. @UltCombo, please open a fresh PR from a branch other than master. If you need guidance, the link @jzaefferer provided has all the info you'll need. For now, I'm going to close this one. |
@mikesherov Yes, I've read that before but had some issues with git rebease at the time. I'll do this right and submit a clean PR at later then. |
Changes:
mousedown
-mouseup
sequence in the same label button..click()
on a label not triggering the input's change handler in Safari - see fiddle. I've replaced the.click()
calls by.simulate( "click" )
and it passes all unit tests now.Fiddle preview