From a2698dc3b5cbbfeeda01115504b1695b3e2807fa Mon Sep 17 00:00:00 2001 From: Ashley Harrison Date: Tue, 29 Jul 2025 09:30:18 +0100 Subject: [PATCH] Chore: Unskip some a11y story checks and fix any associated issues (#108613) * fix some a11y issues with the stories * fix lockfile * fix tests * put aria-label on * add aria-describedby * undo changes to VizLegendTable * use useID for image id --- .betterer.results | 84 ------------ .../grafana-data/src/themes/createColors.ts | 2 +- .../AutoSaveField/AutoSaveField.story.tsx | 18 ++- .../src/components/Button/Button.story.tsx | 10 +- .../components/Carousel/Carousel.story.tsx | 2 - .../src/components/Carousel/Carousel.test.tsx | 9 +- .../src/components/Carousel/Carousel.tsx | 30 +++-- .../components/Cascader/Cascader.story.tsx | 22 ++- .../ColorPicker/ColorPickerInput.story.tsx | 23 ++-- .../ConfirmButton/ConfirmButton.story.tsx | 2 - .../components/ConfirmButton/DeleteButton.tsx | 7 +- .../ContextMenu/ContextMenu.story.tsx | 5 +- .../DateTimePickers/TimeOfDayPicker.story.tsx | 23 ++-- .../DateTimePickers/TimeOfDayPicker.tsx | 3 + .../src/components/Forms/Field.story.tsx | 24 ++-- .../src/components/Forms/FieldSet.story.tsx | 15 ++- .../src/components/Forms/Form.story.tsx | 126 ++++++++++-------- .../components/Forms/InlineField.story.tsx | 28 ++-- .../InlineToast/InlineToast.story.tsx | 10 +- .../src/components/Input/Input.story.tsx | 37 ++--- .../src/components/Layout/Grid/Grid.story.tsx | 18 +-- .../LoadingBar/LoadingBar.story.tsx | 2 - .../src/components/LoadingBar/LoadingBar.tsx | 2 +- .../PanelChrome/PanelChrome.story.tsx | 2 +- .../src/components/Segment/Segment.story.tsx | 6 +- .../components/Segment/SegmentAsync.story.tsx | 6 +- .../components/Segment/SegmentInput.story.tsx | 5 +- .../src/components/Segment/styles.ts | 8 +- .../components/Select/SelectPerf.story.tsx | 37 +++-- .../StatsPicker/StatsPicker.story.tsx | 29 ++-- .../src/components/Switch/Switch.story.tsx | 11 +- .../TableInputCSV/TableInputCSV.story.tsx | 4 - .../TableInputCSV/TableInputCSV.tsx | 3 +- .../src/components/Tags/TagList.story.tsx | 2 - .../src/components/Tags/TagList.tsx | 10 +- .../src/components/Text/Text.story.tsx | 2 - .../components/ThemeDemos/ThemeDemo.story.tsx | 2 - .../src/components/ThemeDemos/ThemeDemo.tsx | 39 ++++-- .../ThemeDemos/Typography.story.tsx | 10 +- .../ToolbarButton/ToolbarButton.story.tsx | 12 +- .../src/utils/storybook/StoryExample.tsx | 14 +- public/locales/en-US/grafana.json | 4 + public/sass/_variables.light.generated.scss | 2 +- 43 files changed, 348 insertions(+), 362 deletions(-) diff --git a/.betterer.results b/.betterer.results index 1ab5b19047e..95894921943 100644 --- a/.betterer.results +++ b/.betterer.results @@ -4229,36 +4229,12 @@ exports[`no skipping a11y tests in stories`] = { "packages/grafana-alerting/src/grafana/contactPoints/components/ContactPointSelector/ContactPointSelector.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/AutoSaveField/AutoSaveField.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Button/Button.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Carousel/Carousel.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Cascader/Cascader.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/ColorPicker/ColorPicker.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/ColorPicker/ColorPickerInput.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Combobox/MultiCombobox.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/ConfirmButton/ConfirmButton.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/ContextMenu/ContextMenu.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/DateTimePickers/TimeOfDayPicker.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/FileDropzone/FileDropzone.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], @@ -4268,45 +4244,21 @@ exports[`no skipping a11y tests in stories`] = { "packages/grafana-ui/src/components/Forms/Checkbox.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/Forms/Field.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Forms/FieldArray.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/Forms/FieldSet.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Forms/Form.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Forms/InlineField.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Forms/RadioButtonGroup/RadioButtonGroup.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/InlineToast/InlineToast.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Input/Input.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/InteractiveTable/InteractiveTable.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/Layout/Grid/Grid.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Layout/Stack/Stack.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], "packages/grafana-ui/src/components/Link/TextLink.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/LoadingBar/LoadingBar.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Menu/Menu.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], @@ -4325,54 +4277,18 @@ exports[`no skipping a11y tests in stories`] = { "packages/grafana-ui/src/components/ScrollContainer/ScrollContainer.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/Segment/Segment.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Segment/SegmentAsync.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Segment/SegmentInput.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Select/Select.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/Select/SelectPerf.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Slider/RangeSlider.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], "packages/grafana-ui/src/components/Slider/Slider.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/StatsPicker/StatsPicker.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Switch/Switch.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/Table/Table.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], - "packages/grafana-ui/src/components/TableInputCSV/TableInputCSV.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Tags/TagList.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/Text/Text.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/ThemeDemos/ThemeDemo.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/ThemeDemos/Typography.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], - "packages/grafana-ui/src/components/ToolbarButton/ToolbarButton.story.tsx:5381": [ - [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] - ], "packages/grafana-ui/src/components/VizLayout/VizLayout.story.tsx:5381": [ [0, 0, 0, "No skipping of a11y tests in stories. Please fix the component or story instead.", "5381"] ], diff --git a/packages/grafana-data/src/themes/createColors.ts b/packages/grafana-data/src/themes/createColors.ts index 9f9afcbfaa9..706f87d280e 100644 --- a/packages/grafana-data/src/themes/createColors.ts +++ b/packages/grafana-data/src/themes/createColors.ts @@ -186,7 +186,7 @@ class LightColors implements ThemeColorsBase> { text = { primary: `rgba(${this.blackBase}, 1)`, secondary: `rgba(${this.blackBase}, 0.75)`, - disabled: `rgba(${this.blackBase}, 0.64)`, + disabled: `rgba(${this.blackBase}, 0.65)`, link: this.primary.text, maxContrast: palette.black, }; diff --git a/packages/grafana-ui/src/components/AutoSaveField/AutoSaveField.story.tsx b/packages/grafana-ui/src/components/AutoSaveField/AutoSaveField.story.tsx index 24df1318d55..c19df03d2c3 100644 --- a/packages/grafana-ui/src/components/AutoSaveField/AutoSaveField.story.tsx +++ b/packages/grafana-ui/src/components/AutoSaveField/AutoSaveField.story.tsx @@ -1,5 +1,5 @@ import { StoryFn, Meta } from '@storybook/react'; -import { useState } from 'react'; +import { useId, useState } from 'react'; import { Combobox } from '../Combobox/Combobox'; import { Checkbox } from '../Forms/Checkbox'; @@ -35,8 +35,6 @@ const meta: Meta = { 'validationMessageHorizontalOverflow', ], }, - // TODO fix a11y issue in story and remove this - a11y: { test: 'off' }, }, argTypes: { saveErrorMessage: { control: 'text' }, @@ -76,10 +74,12 @@ const themeOptions = [ export const Basic: StoryFn = (args) => { const [inputValue, setInputValue] = useState(''); + const id = useId(); return ( {(onChange) => ( { const value = e.currentTarget.value; @@ -105,12 +105,19 @@ export const AllComponents: StoryFn = (args) => { const [checkBoxValue, setCheckBoxValue] = useState(false); const [textAreaValue, setTextAreaValue] = useState(''); const [switchValue, setSwitchValue] = useState(false); + const textId = useId(); + const comboboxId = useId(); + const radioButtonId = useId(); + const checkBoxId = useId(); + const textAreaId = useId(); + const switchId = useId(); return (
{(onChange) => ( { const value = e.currentTarget.value; @@ -123,6 +130,7 @@ export const AllComponents: StoryFn = (args) => { {(onChange) => ( { @@ -139,6 +147,7 @@ export const AllComponents: StoryFn = (args) => { > {(onChange) => ( { @@ -155,6 +164,7 @@ export const AllComponents: StoryFn = (args) => { > {(onChange) => ( { > {(onChange) => (