-
Notifications
You must be signed in to change notification settings - Fork 757
Closed
Labels
css-pseudo-4Current WorkCurrent Work
Description
Current behavior
Matches an element that has user focus or contains an element that has user focus
Expected behavior
Matches an element that contains an element that has user focus
Reasons
-
The current behavior overlaps with that of
:focus(non-orthogonal) -
Consider this nested UI scenario: list view items containing nested buttons. The list view items and the nested buttons are clickable.
- When user presses a list view item, the
:activestate should be applied to it - When user presses a nested button, the button should be styled as
:active, but the list view item should not be. With the current behavior of:focus-within, this is impossible to achieve. However, if the behavior of:focus-withinis changed to the expected behavior above, this can be achieved as follows
/* User presses the list view item, not the buttons */ list-view-item:active:not(:focus-within) { background-color: #0006; } /* User presses a nested button */ button:active { background-color: #0006; }
- When user presses a list view item, the
-
The current behavior can be achieved by combining
:focusand:focus-within
Refercences
https://drafts.csswg.org/selectors-4/#the-focus-within-pseudo
https://stackoverflow.com/questions/33114318/css-prevent-parent-element-getting-active-pseudoclass-when-child-element-is-cl
Metadata
Metadata
Assignees
Labels
css-pseudo-4Current WorkCurrent Work
