Skip to content

Commit 64cdaa8

Browse files
committed
Spinner: Keep the focus on the text field even when using the buttons.
1 parent fb5cad3 commit 64cdaa8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

ui/jquery.ui.spinner.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,7 @@ $.widget( "ui.spinner", {
6262
.wrap( this._uiSpinnerHtml() )
6363
.parent()
6464
// add buttons
65-
.append( this._buttonHtml() )
66-
// add behaviors
67-
.disableSelection();
65+
.append( this._buttonHtml() );
6866
this._hoverable( uiSpinner );
6967

7068
this.element.attr( "role", "spinbutton" );
@@ -108,6 +106,12 @@ $.widget( "ui.spinner", {
108106
.removeClass( "ui-corner-all" );
109107
this._bind( this.buttons, {
110108
mousedown: function( event ) {
109+
// ensure focus is on (or stays on) the text field
110+
event.preventDefault();
111+
if ( document.activeElement !== this.element[ 0 ] ) {
112+
this.element.focus();
113+
}
114+
111115
if ( this._start( event ) === false ) {
112116
return;
113117
}

0 commit comments

Comments
 (0)