mirror of
https://github.com/flarum/core.git
synced 2025-08-02 14:37:49 +02:00
[A11Y] Fix nav drawer being focusable when off-screen on small viewports (#2666)
* Fix nav drawer being focusable when off-screen on small viewports Fixes #2565 * Implement review suggestions * Format
This commit is contained in:
@@ -31,7 +31,24 @@ export default class Drawer {
|
|||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
hide() {
|
hide() {
|
||||||
$('#app').removeClass('drawerOpen');
|
/**
|
||||||
|
* As part of hiding the drawer, this function also ensures that the drawer
|
||||||
|
* correctly animates out, while ensuring it is not part of the navigation
|
||||||
|
* tree while off-screen.
|
||||||
|
*
|
||||||
|
* More info: https://github.com/flarum/core/pull/2666#discussion_r595381014
|
||||||
|
*/
|
||||||
|
|
||||||
|
const $app = $('#app');
|
||||||
|
|
||||||
|
if (!$app.hasClass('drawerOpen')) return;
|
||||||
|
|
||||||
|
const $drawer = $('#drawer');
|
||||||
|
|
||||||
|
// Used to prevent `visibility: hidden` from breaking the exit animation
|
||||||
|
$drawer.css('visibility', 'visible').one('transitionend', () => $drawer.css('visibility', ''));
|
||||||
|
|
||||||
|
$app.removeClass('drawerOpen');
|
||||||
|
|
||||||
if (this.$backdrop) this.$backdrop.remove();
|
if (this.$backdrop) this.$backdrop.remove();
|
||||||
}
|
}
|
||||||
|
@@ -123,6 +123,9 @@
|
|||||||
// the left side of the screen. On other devices, the drawer has no specific
|
// the left side of the screen. On other devices, the drawer has no specific
|
||||||
// appearance.
|
// appearance.
|
||||||
@media @phone {
|
@media @phone {
|
||||||
|
.App:not(.drawerOpen) .App-drawer {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
.drawerOpen {
|
.drawerOpen {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user