Skip to content

useButton doesn't reset its press state when manually focusing on another element within onPressStart #3043

@rostero1

Description

@rostero1

🐛 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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions