From caacf8f5041ad434b8e0dd1069936eb91e4c3394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabr=C3=ADcio=20Matt=C3=A9?= Date: Mon, 26 Nov 2012 20:14:58 -0500 Subject: [PATCH] Button: Let change handler handle display and aria update. Fixed #5518 - Button: Incorrect state after double click in Firefox --- tests/unit/button/button.html | 1 + tests/unit/button/button_events.js | 11 +++++++++++ ui/jquery.ui.button.js | 2 -- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/unit/button/button.html b/tests/unit/button/button.html index 38820999192..ebdc7647055 100644 --- a/tests/unit/button/button.html +++ b/tests/unit/button/button.html @@ -68,6 +68,7 @@

+
diff --git a/tests/unit/button/button_events.js b/tests/unit/button/button_events.js index 7b79c41ea21..b808b59b780 100644 --- a/tests/unit/button/button_events.js +++ b/tests/unit/button/button_events.js @@ -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); diff --git a/ui/jquery.ui.button.js b/ui/jquery.ui.button.js index d6eed67dcc2..1108bd50c79 100644 --- a/ui/jquery.ui.button.js +++ b/ui/jquery.ui.button.js @@ -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() {