Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A11y improvements for meta attributes #4811

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions changelog/unreleased/a11y-improvements-for-meta-attributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Enhancement: A11y improvements for meta attributes

For a11y the html language attribute will be set dynamically <html lang="xx"/>.
For a11y the title will be set automatically following the schema:
sub item (e.G file) - route (e.g All Files) - general name (e.g ownCloud)

https://github.com/owncloud/web/issues/4342
https://github.com/owncloud/web/issues/4338
https://github.com/owncloud/web/pull/4811
37 changes: 30 additions & 7 deletions packages/web-runtime/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,11 @@ export default {
}
},
watch: {
$route() {
this.appNavigationVisible = false
$route: {
immediate: true,
handler: function(to) {
document.title = this.extractPageTitleFromRoute(to)
}
},
capabilities(caps) {
if (!caps) {
Expand All @@ -235,16 +238,17 @@ export default {
}
},
selectedLanguage: {
immediate: true,
handler(language) {
let languageCode = this.$language.defaultLanguage
if (language !== null && language.listValue.values.length > 0) {
languageCode = language.listValue.values[0].stringValue
}
if (languageCode) {
this.$language.current = languageCode
document.documentElement.lang = languageCode
}
},
immediate: true
}
}
},

Expand All @@ -259,9 +263,7 @@ export default {
},

metaInfo() {
const metaInfo = {
title: this.configuration.theme.general.name
}
const metaInfo = {}
if (this.favicon) {
metaInfo.link = [{ rel: 'icon', href: this.favicon }]
}
Expand Down Expand Up @@ -318,6 +320,27 @@ export default {
}

this.appNavigationVisible = false
},
extractPageTitleFromRoute(route) {
const titleSegments = [this.configuration.theme.general.name]

if (route.meta.pageTitle) {
titleSegments.unshift(route.meta.pageTitle)
}

if (route.params.item) {
if (route.name.startsWith('files-')) {
const fileTree = route.params.item.split('/').filter(el => el.length)

if (fileTree.length) {
titleSegments.unshift(fileTree.pop())
}
} else {
titleSegments.unshift(route.params.item)
}
}

return titleSegments.join(' - ')
}
}
}
Expand Down