Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.

Commit af3c4fa

Browse files
committed
rangeslider: force update on mousedown to prevent situation where user has typed in input but input has not yet blured. Fixes #5644 - Rangeslider makes FF (Mac OS) pause for few sec and throw error "too much recursion" when manually enter right value less than left one and click middle slider area
1 parent 70e2aed commit af3c4fa

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

js/widgets/forms/rangeslider.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
6464
"blur": "_change",
6565
"keyup": "_change"
6666
});
67+
this._on({
68+
"mousedown":"_change"
69+
});
6770
this._on( firstHandle, {
6871
"vmousedown": "_dragFirstHandle"
6972
});
@@ -134,21 +137,27 @@ define( [ "jquery", "../../jquery.mobile.core", "../../jquery.mobile.widget", ".
134137
return false;
135138
}
136139

137-
var min = parseFloat( this._inputFirst.val(), 10 ),
140+
var self = this,
141+
min = parseFloat( this._inputFirst.val(), 10 ),
138142
max = parseFloat( this._inputLast.val(), 10 ),
139143
first = $( event.target ).hasClass( "ui-rangeslider-first" ),
140144
thisSlider = first ? this._inputFirst : this._inputLast,
141145
otherSlider = first ? this._inputLast : this._inputFirst;
142-
146+
147+
148+
if( ( this._inputFirst.val() > this._inputLast.val() && event.type === "mousedown" && !$(event.target).hasClass("ui-slider-handle")) ){
149+
thisSlider.blur();
150+
} else if( event.type === "mousedown" ){
151+
return;
152+
}
143153
if ( min > max && !this._sliderTarget ) {
144154
//this prevents min from being greater then max
145155
thisSlider.val( first ? max: min ).slider( "refresh" );
146156
this._trigger( "normalize" );
147157
} else if ( min > max ) {
148158
//this makes it so clicks on the target on either extreme go to the closest handle
149159
thisSlider.val( this._targetVal ).slider( "refresh" );
150-
151-
var self = this;
160+
152161
//You must wait for the stack to unwind so first slider is updated before updating second
153162
setTimeout( function() {
154163
otherSlider.val( first ? min: max ).slider( "refresh" );

0 commit comments

Comments
 (0)