Skip to content

Slider: Setting values or range slider to max, doesn't lock slider #1502

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

Closed
wants to merge 4 commits into from
Closed

Slider: Setting values or range slider to max, doesn't lock slider #1502

wants to merge 4 commits into from

Conversation

atomiomi
Copy link
Contributor

When both values are set to the maximum change them in descending order

Fixes #9046

When both values are set to the maximum change them in descending order

Fixes #9046
valsLength = 0;
rangeValues = [ this.values( 0 ), this.values( 1 ), this._valueMax() ];

if ( this.options.range === true && $.unique( rangeValues ).length === 1 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this check actually necessary? Might be enough to just always do the reverse loop. I tested that locally with the new visual test page and the unit tests, works for both.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've also tested that, it works well. I thought that setting values with reverse loop to the minimum will lock slider, but didn't check it.

@jzaefferer
Copy link
Member

We generally avoid adding more visual test pages, whenever its possible to cover the same behaviour with unit tests instead. In this case, we already have one test that deals with overlapping handles - can you look into extending that test?

@atomiomi
Copy link
Contributor Author

Yes, after writing unit test, visual one will be unuseful I think it should be deleted

@jzaefferer
Copy link
Member

Alright. So you could update the unit test first, once that passes with the patch in place and fails without, refactor the patch as discussed and delete the visual test.

@atomiomi
Copy link
Contributor Author

If everything is ok then I will remove a visual test

@@ -453,9 +460,7 @@ return $.widget( "ui.slider", $.ui.mouse, {
case "values":
this._animateOff = true;
this._refreshValue();
for ( i = 0; i < valsLength; i += 1 ) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not just modify this one line?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Now that the other changes are gone, the separate method isn't needed anymore. The updated for-loop deserves a line comment explaining the reverse iteration.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll fix it.

scottgonzalez pushed a commit that referenced this pull request Jun 9, 2016
When both values are set to the maximum change them in descending order

Fixes #9046
Closes gh-1502

(cherry picked from commit dff1c74)
@eugsa
Copy link

eugsa commented Jul 19, 2016

For me it seems that there is still an issue, please have a look at this fiddle.

I encountered the problem with a slider which has two handle, while setting its values to the maximum. It happens when both values are set at the same time, or when I set the value one by one with the handle [0] first. And strangely, if you set the handle [1] first, then it works perfectly fine.

@scottgonzalez
Copy link
Member

@eugsa It looks like the problem is fixed for standard multi-thumb sliders, but not for range sliders. Would you mind filing an issue at https://bugs.jqueryui.com/newticket and include a link to your test case? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants