Skip to content

[button] focus-visible vs focus when focus persist after clicking with a mouse for keyboard actions #3759

@valerii15298

Description

@valerii15298

Docs feedback

When clicking with a mouse on a button the button stays focused(tailwind focus: styles apply). So when pressing then Space or Enter the button receives click event and handles it.

The issue is that examples use :focus-visible pseudo and not :focus so user does not have visibility that button is currently focused and clicking Space or Enter would trigger some action. In cases when the button does some change or potential destructive action this can be a bad UX.

Suggested docs improvement

Change the examples in button docs to use :focus selector or prevent keyboard actions when button is focused via mouse and not a keyboard.

Example in MUI: https://mui.com/material-ui/react-button/#basic-button
When clicking with mouse and then press Space or Enter the MUI button is not activated(does not receive the click event)

Metadata

Metadata

Assignees

No one assigned

    Labels

    browser: FirefoxAffects or fixes behavior in Mozilla Firefox.component: buttonChanges related to the button component.docsImprovements or additions to the documentation.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions