Skip to content

useButton doesn't forward tabIndex prop #2799

@tinleym

Description

@tinleym

🐛 Bug Report

useButton doesn't forward the tabIndex prop.

🤔 Expected Behavior

useButton returns a tabIndex when passed to it as a parameter.

😯 Current Behavior

useButton does not return a tabIndex when passed to it as a parameter.

💁 Possible Solution

https://github.com/adobe/react-spectrum/blob/main/packages/%40react-aria/button/src/useButton.ts

It looks like tabIndex is excluded if the elementType is the default "button". By my current understanding, this shouldn't be the case (https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex).

🔦 Context

I'm treating tabIndex as a special case in my Button component, which is simple enough, but it would be nice if I and others didn't have to (or debug the issue in the first place).

💻 Code Sample

https://codesandbox.io/s/polished-dust-0k2d1?file=/src/App.js

🌍 Your Environment

Software Version(s)
react-aria 3.12.0
Browser Chrome 97.0.4692.99
Operating System MacOs 11.6.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    waitingWaiting on Issue Author

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions