]> source.dussan.org Git - jquery-ui.git/commitdiff
Spinner: Call _stop() on blur. Fixes #9112 - Spinner keeps changing after losing...
authorScott González <scott.gonzalez@gmail.com>
Fri, 22 Feb 2013 14:15:43 +0000 (09:15 -0500)
committerScott González <scott.gonzalez@gmail.com>
Fri, 22 Feb 2013 14:15:43 +0000 (09:15 -0500)
tests/unit/spinner/spinner_core.js
ui/jquery.ui.spinner.js

index a1179bb35171699a51adf0b36d6b84ac5a18d0bb..bea5f91222c0d0ba93d54b83c670c588aa3d4760 100644 (file)
@@ -80,6 +80,33 @@ test( "keydown PAGE_DOWN on input, decreases value not less than min", function(
        equal( element.val(), 20 );
 });
 
+asyncTest( "blur input while spinning with UP", function() {
+       expect( 3 );
+       var value,
+               element = $( "#spin" ).val( 10 ).spinner();
+
+       function step1() {
+               element.simulate( "keydown", { keyCode: $.ui.keyCode.UP } );
+               equal( element.val(), 11 );
+               setTimeout( step2, 750 );
+       }
+
+       function step2() {
+               value = element.val();
+               ok( value > 11, "repeating while key is down" );
+               element[0].blur();
+               setTimeout( step3, 250 );
+       }
+
+       function step3() {
+               equal( element.val(), value, "stopped repeating on blur" );
+               start();
+       }
+
+       element[ 0 ].focus();
+       setTimeout( step1 );
+});
+
 test( "mouse click on up button, increases value not greater than max", function() {
        expect( 3 );
        var element = $( "#spin" ).val( 18 ).spinner({
index c14ef9370f4824d16fd3fe51957c558ddd8b5881..644b652395a413bc1d2a8a3daa35f59146ffb674 100644 (file)
@@ -102,6 +102,7 @@ $.widget( "ui.spinner", {
                                return;
                        }
 
+                       this._stop();
                        this._refresh();
                        if ( this.previous !== this.element.val() ) {
                                this._trigger( "change", event );