Skip to content

Commit

Permalink
Add focus effects on custom select boxes for accessibility
Browse files Browse the repository at this point in the history
  • Loading branch information
progers committed Feb 28, 2016
1 parent cc2e430 commit d5261ca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@
.customSelect select:focus {
outline: none;
}
/* Custom focus support because we cannot use parent CSS selectors. */
.customSelect#focused {
border-bottom: 1px solid rgba(0,0,0,0.87);
}
</style>
</head>
<body>
Expand Down
14 changes: 14 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,20 @@ window.addEventListener('DOMContentLoaded', function() {
onRightTypeChanged();
});

// Ensure there is a focus effect on the custom type select boxes.
leftTypeSelect.addEventListener('focus', function(event) {
leftTypeSelect.parentElement.setAttribute('id', 'focused');
});
leftTypeSelect.addEventListener('blur', function(event) {
leftTypeSelect.parentElement.removeAttribute('id');
});
rightTypeSelect.addEventListener('focus', function(event) {
rightTypeSelect.parentElement.setAttribute('id', 'focused');
});
rightTypeSelect.addEventListener('blur', function(event) {
rightTypeSelect.parentElement.removeAttribute('id');
});

// Drag and drop support.
var insideCount = 0;
var leftContent = left.querySelector('.content');
Expand Down

0 comments on commit d5261ca

Please sign in to comment.