Skip to content

Commit

Permalink
announce more info
Browse files Browse the repository at this point in the history
  • Loading branch information
JanAckermann committed Mar 16, 2021
1 parent a670209 commit 7b907f2
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions packages/web-runtime/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ export default {
immediate: true,
handler: function(to) {
this.appNavigationVisible = false
this.announceRouteChange(to.meta.pageTitle)
this.announceRouteChange(to)
}
},
capabilities(caps) {
Expand Down Expand Up @@ -277,7 +277,7 @@ export default {
this.$nextTick(() => {
window.addEventListener('resize', this.onResize)
this.onResize()
this.announceRouteChange(this.$router.currentRoute.meta.pageTitle)
this.announceRouteChange(this.$router.currentRoute)
})
},
beforeMount() {
Expand Down Expand Up @@ -324,8 +324,21 @@ export default {
this.appNavigationVisible = false
},
announceRouteChange(pageTitle) {
this.$announcer.polite(`${this.$gettext('Navigated to')} "${pageTitle}"`)
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

0 comments on commit 7b907f2

Please sign in to comment.