mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Spinner: Keep the focus on the text field even when using the buttons.
This commit is contained in:
parent
fb5cad37ce
commit
64cdaa82e6
10
ui/jquery.ui.spinner.js
vendored
10
ui/jquery.ui.spinner.js
vendored
@ -62,9 +62,7 @@ $.widget( "ui.spinner", {
|
|||||||
.wrap( this._uiSpinnerHtml() )
|
.wrap( this._uiSpinnerHtml() )
|
||||||
.parent()
|
.parent()
|
||||||
// add buttons
|
// add buttons
|
||||||
.append( this._buttonHtml() )
|
.append( this._buttonHtml() );
|
||||||
// add behaviors
|
|
||||||
.disableSelection();
|
|
||||||
this._hoverable( uiSpinner );
|
this._hoverable( uiSpinner );
|
||||||
|
|
||||||
this.element.attr( "role", "spinbutton" );
|
this.element.attr( "role", "spinbutton" );
|
||||||
@ -108,6 +106,12 @@ $.widget( "ui.spinner", {
|
|||||||
.removeClass( "ui-corner-all" );
|
.removeClass( "ui-corner-all" );
|
||||||
this._bind( this.buttons, {
|
this._bind( this.buttons, {
|
||||||
mousedown: function( event ) {
|
mousedown: function( event ) {
|
||||||
|
// ensure focus is on (or stays on) the text field
|
||||||
|
event.preventDefault();
|
||||||
|
if ( document.activeElement !== this.element[ 0 ] ) {
|
||||||
|
this.element.focus();
|
||||||
|
}
|
||||||
|
|
||||||
if ( this._start( event ) === false ) {
|
if ( this._start( event ) === false ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user