Skip to content

Conversation

@just-be-dev
Copy link
Contributor

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

This lays the groundwork to resolve #1029. It builds off of #854 and #1292 to allow buttons to have a tooltip that describes why it's disabled. This is forming up to be a fundamental product principle: Don't show the user a disabled action without describing why it's disabled. Further (and a bit of an aside) if there's something the user can do to make it not be disabled then we shouldn't have it disabled at all. We should guide them through the experience of doing whatever they're trying to do.

@vercel
Copy link

vercel bot commented Nov 9, 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 10, 2022 at 6:42PM (UTC)

variant="default"
size="sm"
onClick={() => setShowDiskCreate(true)}
disabledReason="Instance must be stopped to create a disk"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an example and might not hang around.

Comment on lines 126 to 128
<Wrap
when={disabled && disabledReason}
with={<Tooltip content={disabledReason!} childAsAnchor />}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Initially I just was using the hooks API here but the problem with that is that it always executes the tooltip calculation logic which is unnecessary. You can't put a hook behind conditional logic so I converted it over to the component interface so that it could be conditionally included.

</Component>
{tip && (
<Tooltip id={`${id}-tip`} content={tip}>
<Tooltip content={tip}>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

id was unnecessary

@just-be-dev just-be-dev merged commit a49806b into main Nov 10, 2022
@just-be-dev just-be-dev deleted the button-disabled-reason branch November 10, 2022 19:07
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.

Add tooltips for disabled menu items and buttons

3 participants