Skip to content

Commit c49dbe0

Browse files
ruprictscottgonzalez
authored andcommitted
Button: modified the event bindings for focus and blur. Fixed #6711 - checkbox/radio button do not show focused state when using Keyboard Navigation
1 parent e89ae5f commit c49dbe0

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

tests/unit/button/button_tickets.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,14 @@ test( "#6262 - buttonset not applying ui-corner to invisible elements", function
2020
ok( set.find( "label:eq(2)" ).is( ".ui-button.ui-corner-right" ) );
2121
});
2222

23+
test( "#6711 Checkbox/Radiobutton do not Show Focused State when using Keyboard Navigation", function() {
24+
var check = $( "#check" ).button(),
25+
label = $( "label[for='check']" );
26+
ok( !label.is( ".ui-state-focus" ) );
27+
check.focus();
28+
ok( label.is( ".ui-state-focus" ) );
29+
});
30+
2331
test( "#7092 - button creation that requires a matching label does not find label in all cases", function() {
2432
var group = $( "<span><label for='t7092a'/><input type='checkbox' id='t7092a'/></span>" );
2533
group.find( "input:checkbox" ).button();

ui/jquery.ui.button.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,21 @@ $.widget( "ui.button", {
9595
}
9696
$( this ).removeClass( hoverClass );
9797
})
98-
.bind( "focus.button", function() {
99-
// no need to check disabled, focus won't be triggered anyway
100-
$( this ).addClass( focusClass );
101-
})
102-
.bind( "blur.button", function() {
103-
$( this ).removeClass( focusClass );
104-
})
10598
.bind( "click.button", function( event ) {
10699
if ( options.disabled ) {
107100
event.stopImmediatePropagation();
108101
}
109102
});
110103

104+
this.element
105+
.bind( "focus.button", function() {
106+
// no need to check disabled, focus won't be triggered anyway
107+
self.buttonElement.addClass( focusClass );
108+
})
109+
.bind( "blur.button", function() {
110+
self.buttonElement.removeClass( focusClass );
111+
});
112+
111113
if ( toggleButton ) {
112114
this.element.bind( "change.button", function() {
113115
if ( clickDragged ) {

0 commit comments

Comments
 (0)