same but for js

This commit is contained in:
Joachim 2021-12-17 20:53:06 +01:00
parent b15e0e37fc
commit 89713ce685

View file

@ -507,8 +507,10 @@ let BookWyrm = new class {
menuElement.querySelectorAll( menuElement.querySelectorAll(
'a[href]:not([disabled]), button:not([disabled])' 'a[href]:not([disabled]), button:not([disabled])'
)[0].focus(); )[0].focus();
// Enable focus trap // Enable focus trap
menuElement.addEventListener('keydown', this.handleFocusTrap); menuElement.addEventListener('keydown', this.handleFocusTrap);
// Close on Esc // Close on Esc
detailsElement.addEventListener('keydown', handleEscKey); detailsElement.addEventListener('keydown', handleEscKey);
@ -518,6 +520,7 @@ let BookWyrm = new class {
} }
} else { } else {
summaryElement.focus(); summaryElement.focus();
// Disable focus trap // Disable focus trap
menuElement.removeEventListener('keydown', this.handleFocusTrap); menuElement.removeEventListener('keydown', this.handleFocusTrap);