Skip to content
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

📝 Improved documentation on Button #2742

Merged
merged 5 commits into from
Jan 25, 2023

Conversation

denektenina
Copy link
Contributor

Resolves #2724

@denektenina denektenina marked this pull request as ready for review January 20, 2023 17:08
Example All button combinations.
### With tooltip
To display a tooltip on the `Button` you can wrap it in a `Tooltip`. If you need to disable the Button, the button should be disabled using
`aria-disabled` instead of the `disabled` prop because Chrome doesn't expose the hover event on disabled buttons.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is a bit too specific, and therefore not entirely correct. Tooltip also does not work in edge, and in safari there is an onmouseover event, but no onmouseleave event, so the tooltip gets stuck always on. Instead i suggest:

Title: "Disabled buttons and tooltip"
text: "Due to inconsistent browser support for mouse events on disabled buttons, Tooltip should not be used in combination with disabled on Button. Instead use aria-disabled and manually block the button onclick action. This has the added benefit of making the Tooltip accessible for people using keyboard navigation, as the button is still focusable."

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good! Will change

### Accessibility
The `aria-disabled` attribute makes it possible to semantically disable the `Button` without hiding it from assistive technologies, such as screen readers.
In EDS, the `Button` is visually styled as disabled, but it is up to the developer to actually disable the button.
An alternative workaround is wrapping the `Button` inside a fitted `span`.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove the suggestion to use a span since I don't see a scenario where you can't just use aria-disabled, and we shouldn't suggest non-accessible solutions in the documentation unless we really have to

aria-disabled={isSubmitting ? true : false}
onClick={!isSubmitting ? onSubmit : undefined}
>
{isSubmitting ? <Progress.Dots /> : 'Fetch data'}
Copy link
Collaborator

Choose a reason for hiding this comment

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

The progress indicator should have color="primary" as discussed in #2682 (It has been tentatively agreed with Birte this is the better solution)

<>
<Button
aria-disabled={isSubmitting ? true : false}
onClick={!isSubmitting ? onSubmit : undefined}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should add aria-label={isSubmitting ? 'loading data' : null} whenever there is icon only indicating the state

<Tooltip title="This is what a tooltip looks like">
<Button>Hover me</Button>
</Tooltip>
<Tooltip title="Tooltip doesn't show in Chrome">
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we change text to: "This tooltip only shows for people using firefox and using mouse. Don't do this!"

<Tooltip title="Tooltip doesn't show in Chrome">
<Button disabled>Disabled button</Button>
</Tooltip>
<Tooltip title="Tooltip shows in Chrome with aria-disabled">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we change text to: "Tooltip works in all browsers and with keyboard navigation when using aria-disabled"

<Tooltip title="Tooltip shows in Chrome with aria-disabled">
<Button aria-disabled>Aria-disabled button</Button>
</Tooltip>
<Tooltip title="Tooltip shows in Chrome because Button is wrapped in span">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Delete the example using span (for reasons explained above)

@@ -71,3 +71,14 @@ Long list of elements that have a tooltip. Used for testing if tooltip "lag" whe
Inputs of type radio, checkbox and switch will have the tooltip applied to the input element. A good way to get the tooltip to also apply to the label is to simply wrap the input in a span.

<Story id="data-display-tooltip--radio-and-checkboxes" />

### Tooltip on Button
To display a tooltip on the `Button` you can wrap it in the `Tooltip`. If you need to disable the `Button`, the button should be
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the same changes here as I suggested in button docs


export const TooltipOnButton: Story<TooltipProps> = () => (
<>
<Tooltip title="This is what a tooltip looks like">
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do the same changes here as I suggested in the button stories

Copy link
Collaborator

@oddvernes oddvernes left a comment

Choose a reason for hiding this comment

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

LGTM!

@denektenina denektenina merged commit 0b74658 into develop Jan 25, 2023
@denektenina denektenina deleted the nande-2724-tooltip-around-disabled-button branch January 25, 2023 12:55
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.

Tooltip around disabled button is not shown in Chrome (works in Firefox)
2 participants