Skip to content

Commit

Permalink
Make toggletip contents always visible to screen readers.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Feb 11, 2025
1 parent 911372e commit ccb6de4
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 1 addition & 5 deletions themes/finna2/js/finna-layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ finna.layout = (function finnaLayout() {
if (!tipInnerEl) {
return;
}
tipInnerEl.innerHTML = message;

const placement = toggletip.dataset.toggletipPlacement || 'bottom';
const popperInst = Popper.createPopper(
Expand All @@ -358,10 +359,8 @@ finna.layout = (function finnaLayout() {
toggletip.addEventListener('click', () => {
if (tipEl.classList.contains('show')) {
tipEl.classList.remove('show');
tipInnerEl.innerHTML = '';
} else {
window.setTimeout(() => {
tipInnerEl.innerHTML = message;
tipEl.classList.add('show');
popperInst.update();
}, 100);
Expand All @@ -372,22 +371,19 @@ finna.layout = (function finnaLayout() {
document.addEventListener('click', (e) => {
if (toggletip !== e.target) {
tipEl.classList.remove('show');
tipInnerEl.innerHTML = '';
}
});

// Remove toggletip on Esc
toggletip.addEventListener('keydown', (e) => {
if ((e.keyCode || e.which) === 27) {
tipEl.classList.remove('show');
tipInnerEl.innerHTML = '';
}
});

// Remove on blur
toggletip.addEventListener('blur', () => {
tipEl.classList.remove('show');
tipInnerEl.innerHTML = '';
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion themes/finna2/scss/components/finna-toggletip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

.finna-toggletip__bubble {
&:not(.show) {
display: none;
@extend .visually-hidden;
}

.finna-toggletip__bubble--inner {
Expand Down

0 comments on commit ccb6de4

Please sign in to comment.