Skip to content

Support for data-focus-within in RAC #5258

@jaknas

Description

@jaknas

Provide a general summary of the feature here

Originally opened in the discussion: #4849 (comment)

For all grid components that support interactive children, I'd like to have possibility to style the <Item/> component based on whether the focus is contained in the descendant of this <Item/>.

For example:
My solution requires to style a <Row/> component when it's being interacted with. Currently, this can be done with using data-hovered or data-focus-visible selectors. However, when my focus moves to one of the interactive children, there's no attribute on the <Row/> component I could use, that I could use to apply the same styles as e.g data-hovered (that'd signify that this row is being interacted with)

🤔 Expected Behavior?

Additional prop/data-attribute that would be enabled once the focus is on the element's descendants. Best candidate seems to be using focus-within selector, but I'm open to hear about drawbacks of this or some other ideas.

😯 Current Behavior

No way of knowing that focus is contained in the element's descendants.

💁 Possible Solution

Possibly adding the useFocusWithin hook to the TableRow component.

🔦 Context

I'd like to style a grid role="row" element based on whether any of the descendants is currently focused.

💻 Examples

No response

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions