Skip to content

Commit

Permalink
Button: Let change handler handle display and aria update. Fixed #551…
Browse files Browse the repository at this point in the history
…8 - Button: Incorrect state after double click in Firefox
  • Loading branch information
Fabrício Matté authored and mikesherov committed Nov 27, 2012
1 parent 0cc8197 commit caacf8f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions tests/unit/button/button.html
Expand Up @@ -68,6 +68,7 @@ <h2 id="qunit-userAgent"></h2>
</form>

<input type="checkbox" id="check"><label for="check">Toggle</label>
<input type="checkbox" id="check2"><label for="check2">Checkbox</label>

<div><input id="submit" type="submit" value="Label"></div>

Expand Down
11 changes: 11 additions & 0 deletions tests/unit/button/button_events.js
Expand Up @@ -23,4 +23,15 @@ test( "when button loses focus, ensure active state is removed (#8559)", functio
}).focus().simulate( "keydown", { keyCode: $.ui.keyCode.ENTER } ).simulate( "keypress", { keyCode: $.ui.keyCode.ENTER } );
});

test( "ensure checked and aria after single click on checkbox label button", function() {
expect( 3 );

$("#check2").button().change( function() {
var lbl = $( this ).button("widget");
ok( this.checked, "checked ok" );
ok( lbl.attr("aria-pressed") === "true", "aria ok" );
ok( lbl.hasClass("ui-state-active"), "ui-state-active ok" );
}).button("widget").simulate("click");
});

})(jQuery);
2 changes: 0 additions & 2 deletions ui/jquery.ui.button.js
Expand Up @@ -147,8 +147,6 @@ $.widget( "ui.button", {
if ( options.disabled || clickDragged ) {
return false;
}
$( this ).toggleClass( "ui-state-active" );
that.buttonElement.attr( "aria-pressed", that.element[0].checked );
});
} else if ( this.type === "radio" ) {
this.buttonElement.bind( "click" + this.eventNamespace, function() {
Expand Down

0 comments on commit caacf8f

Please sign in to comment.