Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[A11Y] Fix nav drawer being focusable when off-screen on small viewports #2666

Merged
merged 3 commits into from
Mar 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion js/src/common/utils/Drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,24 @@ export default class Drawer {
* @public
*/
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();
}
Expand Down
3 changes: 3 additions & 0 deletions less/common/App.less
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
// the left side of the screen. On other devices, the drawer has no specific
// appearance.
@media @phone {
.App:not(.drawerOpen) .App-drawer {
visibility: hidden;
}
.drawerOpen {
overflow: hidden;
}
Expand Down