Skip to content

Commit

Permalink
added route change announcement
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAckermann committed Mar 16, 2021
1 parent 4b5f002 commit e77c658
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/unreleased/enhancement-live-region-updates
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Enhancement: Implement live region updates on route changes

https://github.com/owncloud/web/pull/4812
https://github.com/owncloud/web/issues/4346
4 changes: 3 additions & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "ownCloud web runtime",
"license": "AGPL-3.0",
"devDependencies": {
"@vue-a11y/announcer": "^2.1.0",
"easygettext": "^2.16.1",
"inert-polyfill": "^0.2.5",
"lodash-es": "^4.17.20",
Expand All @@ -26,5 +27,6 @@
"vuex-persist": "2.0.1",
"vuex-router-sync": "^5.0.0",
"wicked-good-xpath": "^1.3.0"
}
},
"dependencies": {}
}
27 changes: 24 additions & 3 deletions packages/web-runtime/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div class="uk-height-1-1">
<VueAnnouncer />
<skip-to target="main">Skip to main</skip-to>
<div id="Web" class="uk-height-1-1">
<div
Expand Down Expand Up @@ -215,8 +216,12 @@ export default {
}
},
watch: {
$route() {
this.appNavigationVisible = false
$route: {
immediate: true,
handler: function(to) {
this.appNavigationVisible = false
this.announceRouteChange(to)
}
},
capabilities(caps) {
if (!caps) {
Expand Down Expand Up @@ -272,9 +277,9 @@ export default {
this.$nextTick(() => {
window.addEventListener('resize', this.onResize)
this.onResize()
this.announceRouteChange(this.$router.currentRoute)
})
},
beforeMount() {
this.initAuth()
},
Expand Down Expand Up @@ -318,6 +323,22 @@ export default {
}
this.appNavigationVisible = false
},
announceRouteChange(route) {
const titleSegments = [route.meta.pageTitle || route.name]
if (route.params.item) {
if (route.name.startsWith('files-')) {
const fileTree = route.params.item.split('/').filter(el => el.length)
if (fileTree.length) {
titleSegments.push(fileTree.pop())
}
} else {
titleSegments.push(route.params.item)
}
}
this.$announcer.polite(`${this.$gettext('Navigated to')} "${titleSegments.join(' - ')}"`)
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/web-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import VueClipboard from 'vue-clipboard2'
import VueScrollTo from 'vue-scrollto'
import VueMeta from 'vue-meta'
import Vue2TouchEvents from 'vue2-touch-events'
import VueAnnouncer from '@vue-a11y/announcer'

// --- Gettext ----
import GetTextPlugin from 'vue-gettext'
Expand Down Expand Up @@ -64,6 +65,7 @@ Vue.use(VueMeta, {
})
Vue.use(ChunkedUpload)
Vue.use(Vue2TouchEvents)
Vue.use(VueAnnouncer)

Vue.component('drag', Drag)
Vue.component('drop', Drop)
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,11 @@
"@typescript-eslint/types" "4.14.1"
eslint-visitor-keys "^2.0.0"

"@vue-a11y/announcer@^2.1.0":
version "2.1.0"
resolved "https://registry.yarnpkg.com/@vue-a11y/announcer/-/announcer-2.1.0.tgz#ed725e90b91870c76285840e0aaa637cfafbf27f"
integrity sha512-7V1osiJQxZPBA+2duF2nZugwgbIba/yvKLsHWvGIBJGY0VZhR4vYyFH3VFyFH2Yi46tHEVBN+X+a0uQaJMhCsQ==

"@vue/[email protected]":
version "3.0.5"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.0.5.tgz#a6e54cabe9536e74c6513acd2649f311af1d43ac"
Expand Down

0 comments on commit e77c658

Please sign in to comment.