useButton doesn't reset its press state when manually focusing on another element within `onPressStart`
See original GitHub issue🐛 Bug Report
Calling inputRef.current.focus() from within onPressStart, as in the search field example does not reset the button’s isPress state when using Enter to initiate the click.
🤔 Expected Behavior
isPressed should be false and the color of the button should go back to gray.
😯 Current Behavior
After hitting enter on the button isPressed stays true and the button is red. Pressing it twice will toggle it back.
💁 Possible Solution
🔦 Context
💻 Code Sample
https://codesandbox.io/s/morning-sky-vtetyt?file=/src/App.js
🌍 Your Environment
| Software | Version(s) |
|---|---|
| react-spectrum | @react-aria/button@3.4.3 |
| Browser | Chrome |
| Operating System | MacOS |
🧢 Your Company/Team
🕷 Tracking Issue (optional)
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
useSelect can't use click to open select anymore and ... - GitHub
Bug Report I have implemented the useSelect in my dropdown/select ... useButton doesn't reset its press state when manually focusing on ...
Read more >How to make an element correctly reset its state and pass ...
You are setting a focus, whenever some transition finishes. But it is incorrect, you have to focus your input only when "open" transition ......
Read more >useButton – React Aria - React Spectrum Libraries
Documentation for useButton in the React Aria package. ... focus behavior, and ARIA props for both native button elements and custom element types....
Read more >useComboBox – React Aria - NET
Documentation for useComboBox in the React Aria package. ... that browser focus remains within the ComboBox <input> element even when interacting with the ......
Read more >Inconsistent behavior among browsers when clicking on buttons
I noticed browsers were inconsistent in how they handle a click on a button element. Some browsers choose to focus on the button....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’m trying to recreate the search example. If I hide the remove button, as shown in the demo, then the issue will likely resolve itself. It’s probably a better UX than keeping it up all the time anyway.
Just as a fyi, I encountered this same issue here: https://github.com/adobe/react-spectrum/issues/2867#issuecomment-1045050777. A possible
isPressedcleanup improvement is mentioned there, closing this issue as a dupe for now.