Skip to content

Commit cca5f62

Browse files
author
Brad Greenlee
committed
Fix issues with focus and keyboard navigation of draggable range.
1 parent f449f26 commit cca5f62

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

ui/jquery.ui.slider.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,16 +146,16 @@ $.widget( "ui.slider", $.ui.mouse, {
146146
curVal,
147147
newVal,
148148
step;
149-
149+
150150
if ( self.options.disabled ) {
151151
return;
152152
}
153153

154154
if ( isRange ) {
155-
this._startRangeDragging();
155+
self._startRangeDragging();
156156
index = 0;
157157
} else {
158-
this._rangeDragging = false;
158+
self._rangeDragging = false;
159159
}
160160

161161
switch ( event.keyCode ) {
@@ -178,7 +178,7 @@ $.widget( "ui.slider", $.ui.mouse, {
178178
}
179179
break;
180180
}
181-
181+
182182
step = self.options.step;
183183
if ( self.options.values && self.options.values.length ) {
184184
curVal = newVal = self.values( index );
@@ -216,13 +216,13 @@ $.widget( "ui.slider", $.ui.mouse, {
216216
}
217217

218218
self._slide( event, index, newVal );
219-
219+
220220
return ret;
221-
221+
222222
})
223223
.keyup(function( event ) {
224224
var index = $( this ).data( "index.ui-slider-handle" );
225-
225+
226226
if ( self._keySliding ) {
227227
self._keySliding = false;
228228
self._stop( event, index );
@@ -318,13 +318,17 @@ $.widget( "ui.slider", $.ui.mouse, {
318318
return false;
319319
}
320320

321-
if ( !this._rangeDragging ) {
321+
if ( this._rangeDragging ) {
322+
this.range
323+
.addClass( "ui-state-active" )
324+
.focus();
325+
} else {
322326
this._mouseSliding = true;
323327

324328
self._handleIndex = index;
325329

326330
closestHandle
327-
.addClass("ui-state-active")
331+
.addClass( "ui-state-active" )
328332
.focus();
329333

330334
var offset = closestHandle.offset();
@@ -364,14 +368,15 @@ $.widget( "ui.slider", $.ui.mouse, {
364368
},
365369

366370
_mouseStop: function( event ) {
367-
this.handles.removeClass( "ui-state-active" );
368371
this._mouseSliding = false;
369372
if ( this._rangeDragging ) {
373+
this.range.removeClass( "ui-state-active" );
370374
for ( var i = 0; i < 2; i++ ) {
371375
this._stop( event, i );
372376
this._change( event, i );
373377
}
374378
} else {
379+
this.handles.removeClass( "ui-state-active" );
375380
this._stop( event, this._handleIndex );
376381
this._change( event, this._handleIndex );
377382
}
@@ -439,8 +444,11 @@ $.widget( "ui.slider", $.ui.mouse, {
439444
if ( this.options.values && this.options.values.length ) {
440445
otherVal = this.values( index ? 0 : 1 );
441446

442-
if ( ( this.options.values.length === 2 && this.options.range === true ) &&
443-
( ( index === 0 && newVal > otherVal) || ( index === 1 && newVal < otherVal ) )
447+
if ( ( this.options.values.length === 2 &&
448+
this.options.range === true &&
449+
this._rangeDragging === false ) &&
450+
( ( index === 0 && newVal > otherVal) ||
451+
( index === 1 && newVal < otherVal ) )
444452
) {
445453
newVal = otherVal;
446454
}

0 commit comments

Comments
 (0)