Add skip links for "skip to main content" and "skip to search results" (#445)

This commit is contained in:
Florentin Schleuß
2022-05-18 03:31:58 +02:00
committed by GitHub
parent 095a936891
commit e7c70945e6
2 changed files with 51 additions and 2 deletions

View File

@@ -228,7 +228,7 @@
<LogoAnimated aria-hidden="true" />
<p>Loading...</p>
</div>
<div v-else role="list" aria-label="Search results">
<div v-else id="search-results" role="list" aria-label="Search results">
<SearchResult
v-for="result in results"
:id="result.slug ? result.slug : result.project_id"
@@ -326,6 +326,8 @@ export default {
maxResults: 20,
sidebarMenuOpen: false,
skipLink: '#search-results',
}
},
async fetch() {
@@ -395,6 +397,17 @@ export default {
},
},
},
created() {
// This is currently using the global event bus as I couldn't figure out how to use the local one
this.$nuxt.$emit('registerSkipLink', {
id: '#search-results',
text: 'Skip to Search Results',
})
},
destroyed() {
// Not sure about this
this.$nuxt.$emit('registerSkipLink')
},
methods: {
async clearFilters() {
for (const facet of [...this.facets]) await this.toggleFacet(facet, true)