From a8bd88785cde3a50c357383f4fd0e7de7790b4e2 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Sat, 23 Nov 2024 03:37:39 +1100 Subject: [PATCH] [8.x] [Search][a11y] Fixing wrong navigation sequence after Reset or Save Default Settings (#201163) (#201404) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.x`: - [[Search][a11y] Fixing wrong navigation sequence after Reset or Save Default Settings (#201163)](https://github.com/elastic/kibana/pull/201163) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: José Luis González --- .../settings/default_settings_flyout.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/settings/default_settings_flyout.tsx b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/settings/default_settings_flyout.tsx index 3c109e2135726..e62c08f3cdaa9 100644 --- a/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/settings/default_settings_flyout.tsx +++ b/x-pack/plugins/enterprise_search/public/applications/enterprise_search_content/components/settings/default_settings_flyout.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { useRef } from 'react'; import { useValues, useActions } from 'kea'; @@ -56,6 +56,8 @@ export const DefaultSettingsFlyout: React.FC = ({ 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(null); return ( @@ -81,6 +83,7 @@ export const DefaultSettingsFlyout: React.FC = ({ cl data-telemetry-id="entSearchContent-defaultSettingsFlyout-ingestPipelinesLink" href={docLinks.ingestPipelines} target="_blank" + ref={firstFocusInFlyoutRef} > {i18n.translate( 'xpack.enterpriseSearch.defaultSettingsFlyout.body.description.ingestPipelinesLink.link', @@ -204,7 +207,10 @@ export const DefaultSettingsFlyout: React.FC = ({ 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', { @@ -218,7 +224,10 @@ export const DefaultSettingsFlyout: React.FC = ({ 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', {