Skip to content

Conversation

@just-be-dev
Copy link
Contributor

@just-be-dev just-be-dev commented Nov 8, 2022

disabled buttons have a bit of an accessibility problem in that they can't be tabbed to. While they technically still show up in the accessibility tree, they're often effectively invisible when many screen readers rely on tabbing behavior to announce UI elements.

This PR alters the button's disabled prop to add a visually-disabled class instead of the disabled attribute. When the disabled prop is present it turns the onClick and onMouseDown props to no-ops. To preserve the styling I've overridden the default disabled tailwind to support both the disabled pseudo selector and the visually-disabled class.

Follow-ups

Once #1288 is merged I'm going to follow up with an update to make it easier to attach tooltips to elements and add a disabledReason prop to the button to be able to invoke a tooltip to say why a button is disabled.

@vercel
Copy link

vercel bot commented Nov 8, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
console-ui-storybook ✅ Ready (Inspect) Visit Preview Nov 8, 2022 at 10:16PM (UTC)

addVariant('children', '& > *')
addVariant('between', '& > * + *')
addVariant('selected', '.is-selected &')
addVariant('disabled', '&.visually-disabled, &:disabled')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥

e.stopPropagation()
e.preventDefault()
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love this. Hope we don't find this breaks some other click behavior in the container.

Copy link
Collaborator

@david-crespo david-crespo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

Co-authored-by: David Crespo <david-crespo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants