fix: [ML] Data Frame Analytics: Analytics selection flyout missing title from announcement (#217666)

Closes: https://github.com/elastic/kibana/issues/217511

**Description**
Dialog modal, flyout, field visible title should be announced for the
users, especially using assistive technology to know what dialog modal,
flyout opened, what field is active and what is needed to enter in it.

**Changes made:**
1. Set correct value for `aria-labelledby` attr.
This commit is contained in:
Alexey Antonov 2025-04-15 15:17:20 +03:00 committed by GitHub
parent fa2d3912f4
commit 4399248cf0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,6 +19,7 @@ import {
EuiFlexGroup,
EuiFlexItem,
EuiTabbedContent,
useGeneratedHtmlId,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
@ -120,6 +121,9 @@ export function AnalyticsIdSelector({
const [selected, setSelected] = useState<
{ model_id?: string; job_id?: string; analysis_type?: string } | undefined
>();
const flyoutTitleId = useGeneratedHtmlId({
prefix: 'jobSelectorFlyout',
});
const [analyticsJobs, setAnalyticsJobs] = useState<DataFrameAnalyticsConfig[]>([]);
const [trainedModels, setTrainedModels] = useState<TrainedModelConfigResponse[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
@ -268,11 +272,11 @@ export function AnalyticsIdSelector({
<EuiFlyout
onClose={closeFlyout}
data-test-subj="mlFlyoutJobSelector"
aria-labelledby="jobSelectorFlyout"
aria-labelledby={flyoutTitleId}
>
<EuiFlyoutHeader hasBorder>
<EuiTitle size="m">
<h2 id="flyoutTitle">
<h2 id={flyoutTitleId}>
{i18n.translate('xpack.ml.analyticsSelector.flyoutTitle', {
defaultMessage: 'Analytics selection',
})}