feat(cdk/a11y): expose current focus state from cdkMonitorElementFocus & cdkMonitorSubtreeFocus #25423
Labels
feature
This issue represents a new feature or feature request rather than a bug or bug fix
needs triage
This issue needs to be triaged by the team
Feature Description
It would be very helpful to be able to export cdkMonitorElementFocus & cdkMonitorSubtreeFocus directives to read current focus state from template.
This requires:
exportAs
toCdkMonitorFocus
directivefocusOrigin: FocusOrigin
orfocused: boolean
field(s)I would be pleased to suggest a PR.
Use Case
Use case is to be able to easily check the focus state of an element to adapt other parts of the UI (eg. showing/hiding other elements...).
Example:
My current alternative is to declare a custom directive like below:
Note: existing cdkMonitorElementFocus/cdkMonitorSubtreeFocus directive already apply some css classes, which can be used to hide the element. But a css-only solution is not suitable for all scenarios.
The text was updated successfully, but these errors were encountered: