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
GrafanaUI: Define tooltip or aria-label as required for IconButton #69699
GrafanaUI: Define tooltip or aria-label as required for IconButton #69699
Conversation
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 a good change and I like that we are improving a11y! In regards to plugins, I would say it is okay to proceed with this change as long as we don't write any code that relies on the properties being available since the grafana-packages are provided during runtime.
Plugin developers will get an error during build time when upgrading the grafana-packages which feels okay since it is really easy to fix.
Can you also add something in the migration guide from 10.0.x -> 10.1.x about this being a requirement and something that the plugin authors need to provide while upgrading the packages?
https://github.com/grafana/grafana/tree/main/docs/sources/developers/plugins/migration-guide
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.
In full support of this change!
I'd even be tempted to go one step further and make the visual tooltip always required and it doubles up as the aria-label if one isn't explicitly supplied but that might be too prescriptive...
/** Tooltip content to display on hover */ | ||
tooltip?: PopoverContent; | ||
tooltip: PopoverContent; |
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.
You'll need to discriminate further than this because you need to check if the Tooltip passed is a string or a component. If it is a string it can be used as the aria-label, if it is a component the aria-label will have to be explicitly set still.
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.
@ckbedwell I changed the component quite a lot and after discussing what if the tooltip was not a string we decided to keep it as undefined for now. This use case doesn't occur too often so it should be fine.
We also discussed within the Frontend Platform team whether it makes sense to always require a tooltip and we identified some use cases in Grafana where a tooltip is not useful. For instance when IconButtons are used to expand context. They show a chevron and we think the icon is unambiguous in this case.
b27e956
to
3975135
Compare
5a9639a
to
a889fd8
Compare
Backend code coverage report for PR #69699 |
Frontend code coverage report for PR #69699
|
1c4ffc5
to
a2a0a40
Compare
packages/grafana-ui/src/components/IconButton/IconButton.story.tsx
Outdated
Show resolved
Hide resolved
…69699) * refactor: modify interfaces to make tooltip or aria-label required * refactor: change functionality around aria-label and tooltip * refactor: change and add information in storybook documentation * refactor: remove default from tooltip * refactor: IconButton to make tooltip or aria-label required * refactor: Fix tests * refactor: Fix tests * refactor: Fix tests * refactor: Fix tests * feat: add migration guide for breaking change * feat: add latest requirements to storybook docs * refactor: separate iconbutton story with and without tooltip * refactor: remove exported baseArgs * refactor: clean up and restructure original story * refactor: adjust styling * refactor: enable control for tooltip * refactor: clean up * refactor: enable control for aria-label * refactor: fix theme getting the wrong theme * refactor: fix tests * refactor: adjust story * refactor: remove confusing story * refactor: adjust controls for stories
…69699) * refactor: modify interfaces to make tooltip or aria-label required * refactor: change functionality around aria-label and tooltip * refactor: change and add information in storybook documentation * refactor: remove default from tooltip * refactor: IconButton to make tooltip or aria-label required * refactor: Fix tests * refactor: Fix tests * refactor: Fix tests * refactor: Fix tests * feat: add migration guide for breaking change * feat: add latest requirements to storybook docs * refactor: separate iconbutton story with and without tooltip * refactor: remove exported baseArgs * refactor: clean up and restructure original story * refactor: adjust styling * refactor: enable control for tooltip * refactor: clean up * refactor: enable control for aria-label * refactor: fix theme getting the wrong theme * refactor: fix tests * refactor: adjust story * refactor: remove confusing story * refactor: adjust controls for stories
…69699) * refactor: modify interfaces to make tooltip or aria-label required * refactor: change functionality around aria-label and tooltip * refactor: change and add information in storybook documentation * refactor: remove default from tooltip * refactor: IconButton to make tooltip or aria-label required * refactor: Fix tests * refactor: Fix tests * refactor: Fix tests * refactor: Fix tests * feat: add migration guide for breaking change * feat: add latest requirements to storybook docs * refactor: separate iconbutton story with and without tooltip * refactor: remove exported baseArgs * refactor: clean up and restructure original story * refactor: adjust styling * refactor: enable control for tooltip * refactor: clean up * refactor: enable control for aria-label * refactor: fix theme getting the wrong theme * refactor: fix tests * refactor: adjust story * refactor: remove confusing story * refactor: adjust controls for stories
What is this feature?
In order to make sure every IconButton provides information about its purpose I now defined the tooltip or aria-label as required.
Why do we need this feature?
A11y reason: In case there is no aria-label set the tooltip is used to provide the required information for screen readers.
Consistency in GrafanaUI: Adding IconButton without proper information can be misleading and frustrating for users. This applies to all IconButtons.
Who is this feature for?
Everyone
Which issue(s) does this PR fix?:
Fixes #66346
Special notes for your reviewer:
Please check that:
Release notice breaking change
For accessibility reasons
tooltip
oraria-label
are now required properties forIconButton
. In order to continue to useIconButton
, you must ensure allIconButton
components have a corresponding tooltip or aria-label text. The tooltip text will also be used as the aria-label if you didn't set one separately. In case you add an aria-label the IconButton will not show a tooltip.