From a8339002197076efe07da1d6c016470015f88292 Mon Sep 17 00:00:00 2001 From: Pascal Wengerter Date: Fri, 28 May 2021 14:43:29 +0100 Subject: [PATCH] Prevent focus from being set to breadcrumb if route changes --- .../web-app-files/src/mixins/accessibleBreadcrumb.js | 6 ++++-- packages/web-app-files/src/views/Personal.vue | 9 +++++---- packages/web-app-files/src/views/PublicFiles.vue | 10 +++++++--- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/web-app-files/src/mixins/accessibleBreadcrumb.js b/packages/web-app-files/src/mixins/accessibleBreadcrumb.js index 09e258db27d..3241ed0d7ab 100644 --- a/packages/web-app-files/src/mixins/accessibleBreadcrumb.js +++ b/packages/web-app-files/src/mixins/accessibleBreadcrumb.js @@ -6,7 +6,7 @@ export default { ...mapGetters('Files', ['activeFilesCount']) }, methods: { - accessibleBreadcrumb_focusAndAnnounceBreadcrumb() { + accessibleBreadcrumb_focusAndAnnounceBreadcrumb(sameRoute) { const activeBreadcrumb = last( document.getElementById('files-breadcrumb').children[0].children ) @@ -29,7 +29,9 @@ export default { invisibleHint.innerHTML = translatedHint activeBreadcrumb.append(invisibleHint) - activeBreadcrumbItem.focus() + if (sameRoute) { + activeBreadcrumbItem.focus() + } } } } diff --git a/packages/web-app-files/src/views/Personal.vue b/packages/web-app-files/src/views/Personal.vue index 5eb574bea07..c1718320618 100644 --- a/packages/web-app-files/src/views/Personal.vue +++ b/packages/web-app-files/src/views/Personal.vue @@ -143,9 +143,10 @@ export default { watch: { $route: { - handler: function() { + handler: function(to, from) { + const sameRoute = to.name === from?.name this.checkHomeFallback() - this.loadResources() + this.loadResources(sameRoute) }, immediate: true }, @@ -184,7 +185,7 @@ export default { } }, - async loadResources() { + async loadResources(sameRoute) { this.loading = true this.CLEAR_CURRENT_FILES_LIST() @@ -219,7 +220,7 @@ export default { this.adjustTableHeaderPosition() this.loading = false - this.accessibleBreadcrumb_focusAndAnnounceBreadcrumb() + this.accessibleBreadcrumb_focusAndAnnounceBreadcrumb(sameRoute) this.scrollToResourceFromRoute() }, diff --git a/packages/web-app-files/src/views/PublicFiles.vue b/packages/web-app-files/src/views/PublicFiles.vue index 78f9e3e42c8..5a6026837a0 100644 --- a/packages/web-app-files/src/views/PublicFiles.vue +++ b/packages/web-app-files/src/views/PublicFiles.vue @@ -131,7 +131,11 @@ export default { watch: { $route: { - handler: 'loadResources', + handler: function(to, from) { + const sameRoute = to.name === from?.name + this.checkHomeFallback() + this.loadResources(sameRoute) + }, immediate: true }, @@ -149,7 +153,7 @@ export default { 'CLEAR_CURRENT_FILES_LIST' ]), - async loadResources() { + async loadResources(sameRoute) { this.loading = true this.CLEAR_CURRENT_FILES_LIST() @@ -204,7 +208,7 @@ export default { } this.loading = false - this.accessibleBreadcrumb_focusAndAnnounceBreadcrumb() + this.accessibleBreadcrumb_focusAndAnnounceBreadcrumb(sameRoute) }, redirectToResolvePage() {