Fixes #7001: Focus the main content container when the page loads

This commit is contained in:
Matt
2021-08-19 14:13:54 -07:00
parent c115c862d1
commit a1183da6d0
8 changed files with 35 additions and 19 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -13,7 +13,7 @@ import { initSideNav } from './sidenav';
import { initRackElevation } from './racks';
import { initLinks } from './links';
function initAll() {
function initDocument() {
for (const init of [
initBootstrap,
initColorMode,
@@ -34,8 +34,18 @@ function initAll() {
}
}
if (document.readyState !== 'loading') {
initAll();
} else {
document.addEventListener('DOMContentLoaded', initAll);
function initWindow() {
const contentContainer = document.querySelector<HTMLElement>('.content-container');
if (contentContainer !== null) {
// Focus the content container for accessible navigation.
contentContainer.focus();
}
}
window.addEventListener('load', initWindow);
if (document.readyState !== 'loading') {
initDocument();
} else {
document.addEventListener('DOMContentLoaded', initDocument);
}

View File

@@ -529,14 +529,20 @@ div.content-container {
overflow-x: hidden;
overflow-y: auto;
@include media-breakpoint-down(lg) {
width: 100%;
// Don't show an outline when the content container is focused.
&:focus,
&:focus-visible {
outline: 0;
}
div.content {
flex: 1;
}
@include media-breakpoint-down(lg) {
width: 100%;
}
// Make the content full-width when printing.
@media print {
width: 100% !important;

View File

@@ -13,7 +13,7 @@
{% include 'base/sidenav.html' %}
{# Body #}
<div class="content-container">
<div class="content-container" tabindex="-2">
{# Netbox Logo, only visible when printing #}
<div class="p-2 printonly">