Fix focustarget in some cases
Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
a9e36aaacb
commit
44f90c7b0b
|
@ -216,16 +216,18 @@ 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?.$el as HTMLElement;
|
||||||
// Make focustarget programmatically focussable
|
if (focusTarget) {
|
||||||
focusTarget.setAttribute("tabindex", "-1");
|
// Make focustarget programmatically focussable
|
||||||
|
focusTarget.setAttribute("tabindex", "-1");
|
||||||
|
|
||||||
// Focus element
|
// Focus element
|
||||||
focusTarget.focus();
|
focusTarget.focus();
|
||||||
|
|
||||||
// Remove tabindex from focustarget.
|
// Remove tabindex from focustarget.
|
||||||
// Reason: https://axesslab.com/skip-links/#update-3-a-comment-from-gov-uk
|
// Reason: https://axesslab.com/skip-links/#update-3-a-comment-from-gov-uk
|
||||||
focusTarget.removeAttribute("tabindex");
|
focusTarget.removeAttribute("tabindex");
|
||||||
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue