Skip to content
Permalink
Browse files

Spinner: Keep the focus on the text field even when using the buttons.

  • Loading branch information
scottgonzalez committed Aug 6, 2011
1 parent fb5cad3 commit 64cdaa82e6736c4b06f6a37ef790820b22d706ed
Showing with 7 additions and 3 deletions.
  1. +7 −3 ui/jquery.ui.spinner.js
@@ -62,9 +62,7 @@ $.widget( "ui.spinner", {
.wrap( this._uiSpinnerHtml() )
.parent()
// add buttons
.append( this._buttonHtml() )
// add behaviors
.disableSelection();
.append( this._buttonHtml() );
this._hoverable( uiSpinner );

this.element.attr( "role", "spinbutton" );
@@ -108,6 +106,12 @@ $.widget( "ui.spinner", {
.removeClass( "ui-corner-all" );
this._bind( this.buttons, {
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 ) {
return;
}

0 comments on commit 64cdaa8

Please sign in to comment.
You can’t perform that action at this time.