adobe / react-spectrum

A collection of libraries and tools that help you build adaptive, accessible, and robust user experiences.
https://react-spectrum.adobe.com
Apache License 2.0
12.98k stars 1.13k forks source link

Focus behavior of `<Select />` component regarding `autoFocus` and `excludeFromTabOrder` does nothing #7221

Open BRobin55 opened 2 weeks ago

BRobin55 commented 2 weeks ago

Provide a general summary of the issue here

The <Select /> component incorporates the props autoFocus and excludeFromTabOrder. Unfortunately the props do not work as described in the documentation.

Select documentation

🤔 Expected Behavior?

When setting the autoFocus prop to true the <Button />inside the <Select />component should be focused on initial render.

When the excludeFromTabOrder prop is being set to true for the <Select /> component, the <Button /> should not be focusable by tabbing.

😯 Current Behavior

By setting the autoFocus prop nothing changes for the focusable behavior. By setting the excludeFromTabOrder prop nothing changes for the focusable behavior.

💁 Possible Solution

No response

🔦 Context

No response

🖥️ Steps to Reproduce

Sandbox

Version

3.18.0

What browsers are you seeing the problem on?

Chrome

If other, please specify.

No response

What operating system are you using?

MacOS 14.6.1 (23G93)

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

snowystinger commented 2 weeks ago

Looks like autoFocus should be passed through Select -> useSelect -> triggerProps, I don't see any reason not to do that.

As for excludeFromTabOrder, that should be removed from the types, we did not intend for that to be there. https://github.com/adobe/react-spectrum/issues/6727#issuecomment-2238868025

BRobin55 commented 2 weeks ago

Great thanks for the quick reply! Seems appropriate to modify useSelect to extend the triggerProps with autoFocus.

Another thing that caught my attention is the autoComplete prop. It doesn’t seem to be used anywhere and, in my opinion, isn’t relevant for the