[9.0] [Discover] Stop keydown event propagation when unified doc tabs are focused (#218131) (#218300) (#218539)

# Backport

This will backport the following commits from `main` to `9.0`:
- [[Discover] Stop keydown event propagation when unified doc tabs are
focused (#218131)
(#218300)](https://github.com/elastic/kibana/pull/218300)

<!--- Backport version: 9.6.6 -->

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

<!--BACKPORT [{"author":{"name":"Alejandro García
Parrondo","email":"31973472+AlexGPlay@users.noreply.github.com"},"sourceCommit":{"committedDate":"2025-04-17T09:02:50Z","message":"[Discover]
Stop keydown event propagation when unified doc tabs are focused
(#218131) (#218300)\n\n## Summary\n\nWhen a tab was focused and the
right or left arrow keys were used it was\nchanging the focused tab and
the selected document, it should only\nchange the selected tab.\n\nFixes
052313e1-aa1e-4d60-9b48-2a22f9b0d90b)\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [ ] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[
]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n###
Identify risks\n\nDoes this PR introduce any risks? For example,
consider risks like hard\nto test bugs, performance regression,
potential of data loss.\n\nDescribe the risk, its severity, and
mitigation for each identified\nrisk. Invite stakeholders and evaluate
how to proceed before merging.\n\n- [ ] [See some
risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n-
[ ]
...","sha":"41ccdb70da28959a9025dab4dfbf36c58228eb67","branchLabelMapping":{"^v9.1.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Discover","release_note:fix","v9.0.0","Team:DataDiscovery","backport:version","v8.18.0","v9.1.0","v8.19.0"],"title":"[Discover]
Stop keydown event propagation when unified doc tabs are focused
(#218131)","number":218300,"url":"https://github.com/elastic/kibana/pull/218300","mergeCommit":{"message":"[Discover]
Stop keydown event propagation when unified doc tabs are focused
(#218131) (#218300)\n\n## Summary\n\nWhen a tab was focused and the
right or left arrow keys were used it was\nchanging the focused tab and
the selected document, it should only\nchange the selected tab.\n\nFixes
052313e1-aa1e-4d60-9b48-2a22f9b0d90b)\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [ ] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[
]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n###
Identify risks\n\nDoes this PR introduce any risks? For example,
consider risks like hard\nto test bugs, performance regression,
potential of data loss.\n\nDescribe the risk, its severity, and
mitigation for each identified\nrisk. Invite stakeholders and evaluate
how to proceed before merging.\n\n- [ ] [See some
risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n-
[ ]
...","sha":"41ccdb70da28959a9025dab4dfbf36c58228eb67"}},"sourceBranch":"main","suggestedTargetBranches":["9.0","8.18","8.19"],"targetPullRequestStates":[{"branch":"9.0","label":"v9.0.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.18","label":"v8.18.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218300","number":218300,"mergeCommit":{"message":"[Discover]
Stop keydown event propagation when unified doc tabs are focused
(#218131) (#218300)\n\n## Summary\n\nWhen a tab was focused and the
right or left arrow keys were used it was\nchanging the focused tab and
the selected document, it should only\nchange the selected tab.\n\nFixes
052313e1-aa1e-4d60-9b48-2a22f9b0d90b)\n\n###
Checklist\n\nCheck the PR satisfies following conditions. \n\nReviewers
should verify this PR satisfies this list as well.\n\n- [ ] Any text
added follows [EUI's
writing\nguidelines](https://elastic.github.io/eui/#/guidelines/writing),
uses\nsentence case text and includes
[i18n\nsupport](https://github.com/elastic/kibana/blob/main/src/platform/packages/shared/kbn-i18n/README.md)\n-
[
]\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\nwas
added for features that require explanation or tutorials\n- [ ] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [ ] If a plugin
configuration key changed, check if it needs to be\nallowlisted in the
cloud and added to the
[docker\nlist](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker)\n-
[ ] This was checked for breaking HTTP API changes, and any
breaking\nchanges have been approved by the breaking-change committee.
The\n`release_note:breaking` label should be applied in these
situations.\n- [ ] [Flaky
Test\nRunner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1)
was\nused on any tests changed\n- [ ] The PR description includes the
appropriate Release Notes section,\nand the correct `release_note:*`
label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n\n###
Identify risks\n\nDoes this PR introduce any risks? For example,
consider risks like hard\nto test bugs, performance regression,
potential of data loss.\n\nDescribe the risk, its severity, and
mitigation for each identified\nrisk. Invite stakeholders and evaluate
how to proceed before merging.\n\n- [ ] [See some
risk\nexamples](https://github.com/elastic/kibana/blob/main/RISK_MATRIX.mdx)\n-
[ ]
...","sha":"41ccdb70da28959a9025dab4dfbf36c58228eb67"}},{"branch":"8.19","label":"v8.19.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Alejandro García Parrondo <31973472+AlexGPlay@users.noreply.github.com>
This commit is contained in:
Kibana Machine 2025-04-17 12:35:13 +02:00 committed by GitHub
parent 199eda6ef7
commit 267bb614aa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 17 additions and 0 deletions

View file

@ -146,6 +146,12 @@ export function UnifiedDocViewerFlyout({
return;
}
const isTabButton = (ev.target as HTMLElement).getAttribute('role') === 'tab';
if (isTabButton) {
// ignore events triggered when the tab buttons are focused
return;
}
if (ev.key === keys.ARROW_LEFT || ev.key === keys.ARROW_RIGHT) {
ev.preventDefault();
ev.stopPropagation();

View file

@ -501,6 +501,17 @@ export default function ({ getService, getPageObjects }: FtrProviderContext) {
await testSubjects.existOrFail(`docViewerFlyoutNavigationPage-2`);
});
it('should not navigate between documents with arrow keys when the tabs are focused', async () => {
await dataGrid.clickRowToggle({ defaultTabId: false });
await discover.isShowingDocViewer();
await testSubjects.existOrFail(`docViewerFlyoutNavigationPage-0`);
await browser.pressKeys(browser.keys.ARROW_RIGHT);
await testSubjects.existOrFail(`docViewerFlyoutNavigationPage-1`);
await testSubjects.click('docViewerTab-doc_view_source');
await browser.pressKeys(browser.keys.ARROW_RIGHT);
await testSubjects.existOrFail(`docViewerFlyoutNavigationPage-1`);
});
it('should close the flyout with the escape key', async () => {
await dataGrid.clickRowToggle({ defaultTabId: false });
expect(await discover.isShowingDocViewer()).to.be(true);