Skip to content

Why elements that aren't focused have data-focus? #2043

Answered by anubra266
babakfp asked this question in Q&A
Discussion options

You must be logged in to vote

The reason for propagating data-states to child elements is to support context-aware styling and accessibility. Some key cases I can point out:

Unified interaction
In components like (menus, dropdowns, or list items with multiple controls), propagating allows all parts of the item to visually respond to the state.
e.g. A focused dropdown item might highlight both the label and its checkbox or icon.

Keyboard Navigation
Accessibility specs often treat the entire item (and its parts) as a single focusable entity for keyboard navigation (e.g., Tab or ArrowKey focus). Propagating data-focus ensures consistent styling or interaction feedback.

Interdependent Styling
Some designs require child el…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@babakfp
Comment options

@anubra266
Comment options

Answer selected by babakfp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants