Skip to content

FocusRing: autoFocus fails to trigger focus on render #7846

@ericbergh

Description

@ericbergh

Provide a general summary of the issue here

The FocusRing component doesn't trigger focus on render when autoFocus is true.

🤔 Expected Behavior?

I expect FocusRing to focus the element passed via children on render when autoFocus is true.

😯 Current Behavior

No focus is given on render. The component does apply focusClass and focusRingClass when applying focus with the keyboard manually.

💁 Possible Solution

I suspect there might be something flawed with the logic seen here: https://github.com/adobe/react-spectrum/blob/main/packages/@react-aria/focus/src/useFocusRing.ts#L48

🔦 Context

No response

🖥️ Steps to Reproduce

I have produced a minimal reproduction here: https://codesandbox.io/p/sandbox/focus-ring-bug-t97nxp

I also included the Button from React Aria Components to show that that works as expected.

Version

3.37.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

Windows

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions