-
Notifications
You must be signed in to change notification settings - Fork 108
Description
It is often useful to hide elements based on CSS. Should be fairly easy to check if an element is visible and be added alongside the focusable check. This messes up with navigation by navigating to an element and getting locked (not sure why it can navigate when visibility is set to hidden in the first place)
Workaround
Currently you can manually update the focusable based on the the visibility, But that ads overhead having to update on each visibility check and if you want to check parents you have to listen for their changes as well. I did it in a hack way by intercepting the addFocusable method and adding this:
component.focusableDefault = toAdd.focusable;
Object.defineProperty(component, 'focusable', { get () { return this.focusableDefault && this.node.checkVisibility({ visibilityProperty: true }); }, set (value: boolean) { this.focusableDefault = value; } });Issues
One issue I can see is if you want to have an element that is already focused and goes invisible you have to update the layout or something. Another one is if you want to intentionally focus on hidden elements, say a popup. Maybe it should be opt in or opt out.