♿ Router: Focus element after URL hash scroll into view navigation
See original GitHub issue♿ feature request
Add a flag for the Router Module to accept a flag to enable focusing of the element to which it is scrolled. In a previous issue (#6595) it was discussed that a feature request is needed to handle this issue.
This feature is required for Accessibility to work properly.
Relevant Package
@angular/router/ExtraOptions
Description
This feature is required for Accessibility to work properly. The anchorScrolling
router option works…however, according to the HTML Standard Spec, Navigate to a Fragment, the last step is:
Move the sequential focus navigation starting point to [the] target.
Describe the solution you’d like
Add a parameter for ExtraOptions as anchorFocus
with the boolean type attached and false as the default
export interface ExtraOptions {
...
anchorScrolling?: 'disabled' | 'enabled',
anchorFocus?: boolean,
...
})
This could be achieved by dynamically setting a tabindex
of '0'
on the targeted element, focusing on that element, then setting the tabindex
to '-1'
. If a tabindex
is already set to '0'
, then just focus on the element.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:7
- Comments:9 (3 by maintainers)
I would like this issue not to be auto-closed due to inactivity.
Sorry, I misread the spec, thanks.
However, after reading the spec, I still don’t think the proposed solution is quite what we want. The target element should not be focused. Instead, it should have the focusing steps run on it. The difference is that if the target element is not focusable, it is not focused. Maybe a bit pedantic, but thought it’d be worth clarifying here.