Skip to content

Commit 75211b7

Browse files
authored
[EuiColorPicker] Ensure EuiFormRow label is applied to EuiColorPicker (#9436)
1 parent a489629 commit 75211b7

File tree

7 files changed

+304
-15
lines changed

7 files changed

+304
-15
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Updated `no-unnamed-interactive-element` to include checking `EuiColorPicker`

packages/eslint-plugin/src/rules/a11y/no_unnamed_interactive_element.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ ruleTester.run('NoUnnamedInteractiveElement', NoUnnamedInteractiveElement, {
4444
code: '<EuiBreadcrumbs aria-label="Breadcrumbs label" />',
4545
languageOptions,
4646
},
47+
{
48+
code: '<EuiColorPicker aria-label="ColorPicker label" />',
49+
languageOptions,
50+
},
4751
// Wrapped in EuiFormRow with label
4852
{
4953
code: '<EuiFormRow label="Row label"><EuiComboBox /></EuiFormRow>',
@@ -53,6 +57,10 @@ ruleTester.run('NoUnnamedInteractiveElement', NoUnnamedInteractiveElement, {
5357
code: '<EuiFormRow label="Row label"><EuiSelect /></EuiFormRow>',
5458
languageOptions,
5559
},
60+
{
61+
code: '<EuiFormRow label="Row label"><EuiColorPicker /></EuiFormRow>',
62+
languageOptions,
63+
},
5664
],
5765
invalid: [
5866
// Missing a11y prop for interactive components
@@ -101,6 +109,11 @@ ruleTester.run('NoUnnamedInteractiveElement', NoUnnamedInteractiveElement, {
101109
languageOptions,
102110
errors: [{ messageId: 'missingA11y' }],
103111
},
112+
{
113+
code: '<EuiColorPicker />',
114+
languageOptions,
115+
errors: [{ messageId: 'missingA11y' }],
116+
},
104117
// Wrapped but missing label
105118
{
106119
code: '<EuiFormRow><EuiComboBox /></EuiFormRow>',
@@ -112,5 +125,10 @@ ruleTester.run('NoUnnamedInteractiveElement', NoUnnamedInteractiveElement, {
112125
languageOptions,
113126
errors: [{ messageId: 'missingA11y' }],
114127
},
128+
{
129+
code: '<EuiFormRow><EuiColorPicker /></EuiFormRow>',
130+
languageOptions,
131+
errors: [{ messageId: 'missingA11y' }],
132+
},
115133
],
116134
});

packages/eslint-plugin/src/rules/a11y/no_unnamed_interactive_element.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ const interactiveComponents = [
2424
'EuiPagination',
2525
'EuiTreeView',
2626
'EuiBreadcrumbs',
27+
'EuiColorPicker',
2728
] as const;
2829

2930
const wrappingComponents = ['EuiFormRow'] as const;
@@ -54,7 +55,10 @@ export const NoUnnamedInteractiveElement = ESLintUtils.RuleCreator.withoutDocs({
5455
function report(opening: TSESTree.JSXOpeningElement) {
5556
if (opening.name.type !== 'JSXIdentifier') return;
5657
const component = opening.name.name;
57-
const allowed = getAllowedA11yPropNamesForComponent(component, a11yConfig).join(', ');
58+
const allowed = getAllowedA11yPropNamesForComponent(
59+
component,
60+
a11yConfig
61+
).join(', ');
5862
context.report({
5963
node: opening,
6064
messageId: 'missingA11y',
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
**Accessibility**
2+
3+
- Fixed `aria-label` not being applied to `EuiColorPicker`'s input element

0 commit comments

Comments
 (0)