Skip to content

Commit dab6e94

Browse files
committed
button: add ui-state-focus on focus, making keyboard navigation possible, and button like 200% more accessible
1 parent d01e785 commit dab6e94

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

ui/jquery.ui.button.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ $.widget( "ui.button", {
3434
var self = this,
3535
options = this.options,
3636
toggleButton = this.type === "checkbox" || this.type === "radio",
37-
hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" );
37+
hoverClass = "ui-state-hover" + ( !toggleButton ? " ui-state-active" : "" ),
38+
focusClass = "ui-state-focus";
3839

3940
if ( options.label === null ) {
4041
options.label = this.buttonElement.html();
@@ -57,6 +58,13 @@ $.widget( "ui.button", {
5758
return;
5859
}
5960
$( this ).removeClass( hoverClass );
61+
})
62+
.bind( "focus.button", function() {
63+
// no need to check disabled, focus won't be triggered anyway
64+
$( this ).addClass( focusClass );
65+
})
66+
.bind( "blur.button", function() {
67+
$( this ).removeClass( focusClass );
6068
});
6169

6270
if ( this.type === "checkbox") {

0 commit comments

Comments
 (0)