-
Notifications
You must be signed in to change notification settings - Fork 15
Enable disabled reason tooltip on button #1293
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| variant="default" | ||
| size="sm" | ||
| onClick={() => setShowDiskCreate(true)} | ||
| disabledReason="Instance must be stopped to create a disk" |
There was a problem hiding this comment.
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.
libs/ui/lib/button/Button.tsx
Outdated
| <Wrap | ||
| when={disabled && disabledReason} | ||
| with={<Tooltip content={disabledReason!} childAsAnchor />} |
There was a problem hiding this comment.
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}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
id was unnecessary
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.