Allow custom focus target for a11y

Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
Thomas Citharel 2022-01-10 10:19:27 +01:00
parent 2ac3755120
commit 411d7eca6c
No known key found for this signature in database
GPG key ID: A061B9DDE0CA0773

View file

@ -216,7 +216,11 @@ export default class App extends Vue {
// Set the focus to the router view // Set the focus to the router view
// https://marcus.io/blog/accessible-routing-vuejs // https://marcus.io/blog/accessible-routing-vuejs
setTimeout(() => { setTimeout(() => {
const focusTarget = this.routerView?.$el as HTMLElement; const focusTarget = (
this.routerView?.$refs?.componentFocusTarget !== undefined
? this.routerView?.$refs?.componentFocusTarget
: this.routerView?.$el
) as HTMLElement;
if (focusTarget) { if (focusTarget) {
// Make focustarget programmatically focussable // Make focustarget programmatically focussable
focusTarget.setAttribute("tabindex", "-1"); focusTarget.setAttribute("tabindex", "-1");