From 5e179a35b23282c4613582755de06a91f6991309 Mon Sep 17 00:00:00 2001
From: zeroinformatique
Date: Sun, 18 Oct 2020 00:22:04 +0200
Subject: viewer: accessibility: set focus on the main area (#273)
github: resolves #177---
viewer/src/views/MainLayout.vue | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
(limited to 'viewer')
diff --git a/viewer/src/views/MainLayout.vue b/viewer/src/views/MainLayout.vue
index 6ef9a3b..9cd518b 100644
--- a/viewer/src/views/MainLayout.vue
+++ b/viewer/src/views/MainLayout.vue
@@ -22,7 +22,7 @@
-
+
@@ -43,6 +43,10 @@ export default class MainLayout extends Vue {
isLoading: boolean = true;
scrollPositions: ScrollPosition = {};
+ get contentDiv() {
+ return this.content.$el as HTMLDivElement;
+ }
+
mounted() {
history.replaceState({ ldgallery: "ENTRYPOINT" }, "");
this.fetchGalleryItems();
@@ -53,11 +57,15 @@ export default class MainLayout extends Vue {
document.body.removeEventListener("fullscreenchange", this.onFullscreenChange);
}
+ moveFocusToContentDiv() {
+ setTimeout(() => this.contentDiv.focus());
+ }
+
@Watch("$route")
routeChanged(newRoute: Route, oldRoute: Route) {
- const el = this.content.$el;
- this.scrollPositions[oldRoute.path] = el.scrollTop;
- this.$nextTick(() => (el.scrollTop = this.scrollPositions[newRoute.path]));
+ this.scrollPositions[oldRoute.path] = this.contentDiv.scrollTop;
+ this.$nextTick(() => (this.contentDiv.scrollTop = this.scrollPositions[newRoute.path]));
+ this.moveFocusToContentDiv();
}
fetchGalleryItems() {
@@ -66,6 +74,7 @@ export default class MainLayout extends Vue {
.fetchConfig()
.then(this.$uiStore.initFromConfig)
.then(this.$galleryStore.fetchGalleryItems)
+ .then(this.moveFocusToContentDiv)
.finally(() => (this.isLoading = false))
.catch(this.displayError);
}
@@ -130,6 +139,9 @@ html {
left: var(--layout-left);
z-index: 3;
overflow-x: hidden;
+ &:focus {
+ outline: none;
+ }
}
}
.fullscreen {
--
cgit v1.2.3