Skip to content

Commit

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

# Backport

This will backport the following commits from `main` to `8.x`:
- [[Search][a11y] Fixing wrong navigation sequence after Reset or Save
Default Settings
(elastic#201163)](elastic#201163)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"José Luis
González","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-11-22T14:42:16Z","message":"[Search][a11y]
Fixing wrong navigation sequence after Reset or Save Default Settings
(elastic#201163)\n\n## Summary\r\n\r\nThis PR solves the
issues\r\nhttps://github.com/elastic/issues/195951
and\r\nhttps://github.com/elastic/issues/195942 getting the focus
on the\r\nfirst interactive element as suggested which is the _ingest
pipelines_\r\nexternal link after pressing enter using the keyboard
navigation either\r\nthe _Reset_ or _Save_ buttons. With this the screen
reader announces the\r\n_ingest pipelines_ content after any of those
previous events.\r\n\r\n![CleanShot 2024-11-22 at 10
16\r\n08](https://github.com/user-attachments/assets/ca8d5739-fcea-42da-af14-031989a84bac)","sha":"56ee08946c1bead9d44829a9adfb11700522e70f","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Project:Accessibility","release_note:skip","v9.0.0","Team:Search","accessibility:
keyboard navigation","backport:prev-minor"],"title":"[Search][a11y]
Fixing wrong navigation sequence after Reset or Save Default
Settings","number":201163,"url":"https://github.com/elastic/kibana/pull/201163","mergeCommit":{"message":"[Search][a11y]
Fixing wrong navigation sequence after Reset or Save Default Settings
(elastic#201163)\n\n## Summary\r\n\r\nThis PR solves the
issues\r\nhttps://github.com/elastic/issues/195951
and\r\nhttps://github.com/elastic/issues/195942 getting the focus
on the\r\nfirst interactive element as suggested which is the _ingest
pipelines_\r\nexternal link after pressing enter using the keyboard
navigation either\r\nthe _Reset_ or _Save_ buttons. With this the screen
reader announces the\r\n_ingest pipelines_ content after any of those
previous events.\r\n\r\n![CleanShot 2024-11-22 at 10
16\r\n08](https://github.com/user-attachments/assets/ca8d5739-fcea-42da-af14-031989a84bac)","sha":"56ee08946c1bead9d44829a9adfb11700522e70f"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/201163","number":201163,"mergeCommit":{"message":"[Search][a11y]
Fixing wrong navigation sequence after Reset or Save Default Settings
(elastic#201163)\n\n## Summary\r\n\r\nThis PR solves the
issues\r\nhttps://github.com/elastic/issues/195951
and\r\nhttps://github.com/elastic/issues/195942 getting the focus
on the\r\nfirst interactive element as suggested which is the _ingest
pipelines_\r\nexternal link after pressing enter using the keyboard
navigation either\r\nthe _Reset_ or _Save_ buttons. With this the screen
reader announces the\r\n_ingest pipelines_ content after any of those
previous events.\r\n\r\n![CleanShot 2024-11-22 at 10
16\r\n08](https://github.com/user-attachments/assets/ca8d5739-fcea-42da-af14-031989a84bac)","sha":"56ee08946c1bead9d44829a9adfb11700522e70f"}}]}]
BACKPORT-->

Co-authored-by: José Luis González <[email protected]>
  • Loading branch information
kibanamachine and JoseLuisGJ authored Nov 22, 2024
1 parent 687013c commit a8bd887
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 a8bd887

Please sign in to comment.