]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Keep the focus on the text field even when using the buttons.
authorScott González <scott.gonzalez@gmail.com>
Sat, 6 Aug 2011 19:07:34 +0000 (15:07 -0400)
committerScott González <scott.gonzalez@gmail.com>
Sat, 6 Aug 2011 19:07:34 +0000 (15:07 -0400)
ui/jquery.ui.spinner.js

index baa3fb5cb4a71c6fe6fb2209c5c6dbb92964562a..2add2d60aec139a95099a6e2acdc10efa7ed3e17 100644 (file)
@@ -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;
                                }