Skip to content

Commit

Permalink
[Search][a11y] Fixing wrong navigation sequence after Reset or Save D…
Browse files Browse the repository at this point in the history
…efault Settings (elastic#201163)

## Summary

This PR solves the issues
elastic#195951 and
elastic#195942 getting the focus on the
first interactive element as suggested which is the _ingest pipelines_
external link after pressing enter using the keyboard navigation either
the _Reset_ or _Save_ buttons. With this the screen reader announces the
_ingest pipelines_ content after any of those previous events.

![CleanShot 2024-11-22 at 10 16
08](https://github.com/user-attachments/assets/ca8d5739-fcea-42da-af14-031989a84bac)
  • Loading branch information
JoseLuisGJ authored and paulinashakirova committed Nov 26, 2024
1 parent a098504 commit 03284e8
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React from 'react';
import React, { useRef } from 'react';

import { useValues, useActions } from 'kea';

Expand Down Expand Up @@ -56,6 +56,8 @@ export const DefaultSettingsFlyout: React.FC<DefaultSettingsFlyoutProps> = ({ cl
reduce_whitespace: reduceWhitespace,
run_ml_inference: runMLInference,
} = pipelineState;
// Reference the first focusable element in the flyout for accessibility on click or Enter key action either Reset or Save button
const firstFocusInFlyoutRef = useRef<HTMLAnchorElement>(null);
return (
<EuiFlyout onClose={closeFlyout} size="s" paddingSize="l">
<EuiFlyoutHeader hasBorder>
Expand All @@ -81,6 +83,7 @@ export const DefaultSettingsFlyout: React.FC<DefaultSettingsFlyoutProps> = ({ cl
data-telemetry-id="entSearchContent-defaultSettingsFlyout-ingestPipelinesLink"
href={docLinks.ingestPipelines}
target="_blank"
ref={firstFocusInFlyoutRef}
>
{i18n.translate(
'xpack.enterpriseSearch.defaultSettingsFlyout.body.description.ingestPipelinesLink.link',
Expand Down Expand Up @@ -204,7 +207,10 @@ export const DefaultSettingsFlyout: React.FC<DefaultSettingsFlyoutProps> = ({ cl
color="primary"
disabled={hasNoChanges}
isLoading={isLoading}
onClick={() => setPipeline(defaultPipeline)}
onClick={() => {
setPipeline(defaultPipeline);
firstFocusInFlyoutRef.current?.focus();
}}
data-test-subj={'entSearchContentSettingsResetButton'}
>
{i18n.translate('xpack.enterpriseSearch.content.settings.resetButtonLabel', {
Expand All @@ -218,7 +224,10 @@ export const DefaultSettingsFlyout: React.FC<DefaultSettingsFlyoutProps> = ({ cl
fill
disabled={hasNoChanges}
isLoading={isLoading}
onClick={() => makeRequest(pipelineState)}
onClick={() => {
makeRequest(pipelineState);
firstFocusInFlyoutRef.current?.focus();
}}
data-test-subj={'entSearchContentSettingsSaveButton'}
>
{i18n.translate('xpack.enterpriseSearch.content.settings.saveButtonLabel', {
Expand Down

0 comments on commit 03284e8

Please sign in to comment.