Skip to content

Commit 685640f

Browse files
[9.2] [SharedUX][A11y] Fixes ML anomaly detection job wizard bucket span error text announcement (elastic#240776) (elastic#240864)
# Backport This will backport the following commits from `main` to `9.2`: - [[SharedUX][A11y] Fixes ML anomaly detection job wizard bucket span error text announcement (elastic#240776)](elastic#240776) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Ángeles Martínez Barrio","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-27T16:25:50Z","message":"[SharedUX][A11y] Fixes ML anomaly detection job wizard bucket span error text announcement (elastic#240776)\n\nCloses https://github.com/elastic/kibana/issues/216297\n\n## Summary\n- To fix bucket span validation error being rendered but not announced,\nan `errorId` is now generated in `bucket_span` and passed to both\n`Description` and `BucketSpanInput`. `EuiFormRow` was not properly\nwiring the correct aria attributes due to the fragment +\nEuiFlexGroup/EuiFlexItem nesting so the error text is now explicitly\nrendered using `EuiFormErrorText`. No visual changes.\n\n### Testing\n\n**Windows + NVDA**\nBefore:\n<img width=\"1730\" height=\"1039\" alt=\"Screenshot 2025-10-27 at 11 42 16\"\nsrc=\"https://github.com/user-attachments/assets/792cd62f-786f-446e-9a3e-c852383818ad\"\n/>\n\nAfter:\n<img width=\"1724\" height=\"1045\" alt=\"Screenshot 2025-10-27 at 11 41 15\"\nsrc=\"https://github.com/user-attachments/assets/c0d955aa-af5e-4946-a32e-d297eb7998ac\"\n/>\n\n**MacOS + VO**\nBefore:\n<img width=\"1225\" height=\"820\" alt=\"Screenshot 2025-10-27 at 11 58 38\"\nsrc=\"https://github.com/user-attachments/assets/54424673-8df7-448f-8b77-2b6cfd17fe0e\"\n/>\n\nAfter:\n<img width=\"1211\" height=\"784\" alt=\"Screenshot 2025-10-27 at 11 58 05\"\nsrc=\"https://github.com/user-attachments/assets/d3d4d3aa-3903-463b-a080-f05b9255c4cb\"\n/>","sha":"9167e9e17ce677236bcf45d185d5b93b56527567","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":[":ml","release_note:skip","Team:SharedUX","backport:version","a11y","v9.3.0","v9.2.1"],"title":"[SharedUX][A11y] Fixes ML anomaly detection job wizard bucket span error text announcement","number":240776,"url":"https://github.com/elastic/kibana/pull/240776","mergeCommit":{"message":"[SharedUX][A11y] Fixes ML anomaly detection job wizard bucket span error text announcement (elastic#240776)\n\nCloses https://github.com/elastic/kibana/issues/216297\n\n## Summary\n- To fix bucket span validation error being rendered but not announced,\nan `errorId` is now generated in `bucket_span` and passed to both\n`Description` and `BucketSpanInput`. `EuiFormRow` was not properly\nwiring the correct aria attributes due to the fragment +\nEuiFlexGroup/EuiFlexItem nesting so the error text is now explicitly\nrendered using `EuiFormErrorText`. No visual changes.\n\n### Testing\n\n**Windows + NVDA**\nBefore:\n<img width=\"1730\" height=\"1039\" alt=\"Screenshot 2025-10-27 at 11 42 16\"\nsrc=\"https://github.com/user-attachments/assets/792cd62f-786f-446e-9a3e-c852383818ad\"\n/>\n\nAfter:\n<img width=\"1724\" height=\"1045\" alt=\"Screenshot 2025-10-27 at 11 41 15\"\nsrc=\"https://github.com/user-attachments/assets/c0d955aa-af5e-4946-a32e-d297eb7998ac\"\n/>\n\n**MacOS + VO**\nBefore:\n<img width=\"1225\" height=\"820\" alt=\"Screenshot 2025-10-27 at 11 58 38\"\nsrc=\"https://github.com/user-attachments/assets/54424673-8df7-448f-8b77-2b6cfd17fe0e\"\n/>\n\nAfter:\n<img width=\"1211\" height=\"784\" alt=\"Screenshot 2025-10-27 at 11 58 05\"\nsrc=\"https://github.com/user-attachments/assets/d3d4d3aa-3903-463b-a080-f05b9255c4cb\"\n/>","sha":"9167e9e17ce677236bcf45d185d5b93b56527567"}},"sourceBranch":"main","suggestedTargetBranches":["9.2"],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240776","number":240776,"mergeCommit":{"message":"[SharedUX][A11y] Fixes ML anomaly detection job wizard bucket span error text announcement (elastic#240776)\n\nCloses https://github.com/elastic/kibana/issues/216297\n\n## Summary\n- To fix bucket span validation error being rendered but not announced,\nan `errorId` is now generated in `bucket_span` and passed to both\n`Description` and `BucketSpanInput`. `EuiFormRow` was not properly\nwiring the correct aria attributes due to the fragment +\nEuiFlexGroup/EuiFlexItem nesting so the error text is now explicitly\nrendered using `EuiFormErrorText`. No visual changes.\n\n### Testing\n\n**Windows + NVDA**\nBefore:\n<img width=\"1730\" height=\"1039\" alt=\"Screenshot 2025-10-27 at 11 42 16\"\nsrc=\"https://github.com/user-attachments/assets/792cd62f-786f-446e-9a3e-c852383818ad\"\n/>\n\nAfter:\n<img width=\"1724\" height=\"1045\" alt=\"Screenshot 2025-10-27 at 11 41 15\"\nsrc=\"https://github.com/user-attachments/assets/c0d955aa-af5e-4946-a32e-d297eb7998ac\"\n/>\n\n**MacOS + VO**\nBefore:\n<img width=\"1225\" height=\"820\" alt=\"Screenshot 2025-10-27 at 11 58 38\"\nsrc=\"https://github.com/user-attachments/assets/54424673-8df7-448f-8b77-2b6cfd17fe0e\"\n/>\n\nAfter:\n<img width=\"1211\" height=\"784\" alt=\"Screenshot 2025-10-27 at 11 58 05\"\nsrc=\"https://github.com/user-attachments/assets/d3d4d3aa-3903-463b-a080-f05b9255c4cb\"\n/>","sha":"9167e9e17ce677236bcf45d185d5b93b56527567"}},{"branch":"9.2","label":"v9.2.1","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ángeles Martínez Barrio <[email protected]>
1 parent b58c6bf commit 685640f

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/bucket_span/bucket_span.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ export const BucketSpan: FC<Props> = ({ setIsValid, hideEstimateButton = false }
2828
const titleId = useGeneratedHtmlId({
2929
prefix: 'bucketSpan',
3030
});
31+
const errorId = useGeneratedHtmlId({
32+
prefix: 'bucketSpanError',
33+
});
3134

3235
useEffect(() => {
3336
jobCreator.bucketSpan = bucketSpan;
@@ -51,7 +54,7 @@ export const BucketSpan: FC<Props> = ({ setIsValid, hideEstimateButton = false }
5154
}, [estimating]);
5255

5356
return (
54-
<Description validation={validation} titleId={titleId}>
57+
<Description validation={validation} titleId={titleId} errorId={errorId}>
5558
<EuiFlexGroup gutterSize="s">
5659
<EuiFlexItem>
5760
<BucketSpanInput
@@ -61,6 +64,7 @@ export const BucketSpan: FC<Props> = ({ setIsValid, hideEstimateButton = false }
6164
bucketSpan={bucketSpan}
6265
isInvalid={validation.valid === false}
6366
disabled={estimating}
67+
errorId={errorId}
6468
/>
6569
</EuiFlexItem>
6670
{hideEstimateButton === false && (

x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/bucket_span/bucket_span_input.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ interface Props {
1515
isInvalid: boolean;
1616
disabled: boolean;
1717
titleId: string;
18+
errorId: string;
1819
}
1920

2021
export const BucketSpanInput: FC<Props> = ({
@@ -23,6 +24,7 @@ export const BucketSpanInput: FC<Props> = ({
2324
isInvalid,
2425
disabled,
2526
titleId,
27+
errorId,
2628
}) => {
2729
return (
2830
<EuiFieldText
@@ -32,6 +34,7 @@ export const BucketSpanInput: FC<Props> = ({
3234
isInvalid={isInvalid}
3335
data-test-subj="mlJobWizardInputBucketSpan"
3436
aria-labelledby={titleId}
37+
aria-describedby={isInvalid ? errorId : undefined}
3538
/>
3639
);
3740
};

x-pack/platform/plugins/shared/ml/public/application/jobs/new_job/pages/components/pick_fields_step/components/bucket_span/description.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@ import type { FC, PropsWithChildren } from 'react';
99
import React, { memo } from 'react';
1010
import { i18n } from '@kbn/i18n';
1111
import { FormattedMessage } from '@kbn/i18n-react';
12-
import { EuiDescribedFormGroup, EuiFormRow } from '@elastic/eui';
12+
import { EuiDescribedFormGroup, EuiFormErrorText, EuiFormRow } from '@elastic/eui';
1313
import type { Validation } from '../../../../../common/job_validator';
1414

1515
interface Props {
1616
validation: Validation;
1717
titleId: string;
18+
errorId: string;
1819
}
1920

2021
export const Description: FC<PropsWithChildren<Props>> = memo(
21-
({ children, validation, titleId }) => {
22+
({ children, validation, titleId, errorId }) => {
2223
const title = i18n.translate('xpack.ml.newJob.wizard.pickFieldsStep.bucketSpan.title', {
2324
defaultMessage: 'Bucket span',
2425
});
@@ -32,9 +33,12 @@ export const Description: FC<PropsWithChildren<Props>> = memo(
3233
/>
3334
}
3435
>
35-
<EuiFormRow error={validation.message} isInvalid={validation.valid === false}>
36+
<EuiFormRow isInvalid={validation.valid === false}>
3637
<>{children}</>
3738
</EuiFormRow>
39+
{validation.valid === false && validation.message && (
40+
<EuiFormErrorText id={errorId}>{validation.message}</EuiFormErrorText>
41+
)}
3842
</EuiDescribedFormGroup>
3943
);
4044
}

0 commit comments

Comments
 (0)