[Discover] Fix query drafts when switching tabs#247968
[Discover] Fix query drafts when switching tabs#247968jughosta merged 21 commits intoelastic:mainfrom
Conversation
...tform/plugins/shared/discover/public/application/main/components/top_nav/discover_topnav.tsx
Show resolved
Hide resolved
| filterManager: data.query.filterManager, | ||
| }); | ||
| const { query } = useQueryStringManager({ | ||
| disabled: disableSubscribingToGlobalDataServices, |
There was a problem hiding this comment.
This what was creating inconsistency in props when switching tabs. The query was switching to another tab query too soon while all other props were still from the previous tab.
| }; | ||
|
|
||
| private onDraftChange = (draft: UnifiedSearchDraft | undefined) => { | ||
| if (this.props.onDraftChange && !isEqual(this.props.draft, draft)) { |
There was a problem hiding this comment.
Just minimizing the number of updates.
davismcphee
left a comment
There was a problem hiding this comment.
Code changes look good to me, and it worked well when testing. Thanks for fixing it! Left minor feedback but I like the overall approach, the less global state the better 👍
I'll wait until you publish to give my final approval, but I think this is good to merge and backport. Maybe we should use release_note:fix though?
...tform/plugins/shared/discover/public/application/main/components/top_nav/discover_topnav.tsx
Show resolved
Hide resolved
...tform/plugins/shared/discover/public/application/main/components/top_nav/discover_topnav.tsx
Show resolved
Hide resolved
src/platform/plugins/shared/unified_search/public/search_bar/lib/use_filter_manager.ts
Outdated
Show resolved
Hide resolved
src/platform/plugins/shared/unified_search/public/search_bar/lib/use_query_string_manager.ts
Outdated
Show resolved
Hide resolved
src/platform/plugins/shared/unified_search/public/search_bar/lib/use_timefilter.ts
Outdated
Show resolved
Hide resolved
|
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
ThomThomson
left a comment
There was a problem hiding this comment.
Unified search drafts functionality changes LGTM. Code review only
davismcphee
left a comment
There was a problem hiding this comment.
Did another round of review and testing, and it's working well, thanks for fixing it!
...tform/plugins/shared/discover/public/application/main/components/top_nav/discover_topnav.tsx
Show resolved
Hide resolved
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]Async chunks
Page load bundle
History
cc @jughosta |
|
Starting backport for target branches: 9.2, 9.3 |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
- Resolves elastic#246896 ## Summary This PR makes sure that the latest query draft is captured and restored when switching tabs. The issue was hidden in UnifiedSearch because it was listening to the global services changes (query, filters, refresh interval) instead of simply using the passed props. This was creating inconsistency between the controlled by Discover props and the controlled by Unified Search props. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit 4930dae) # Conflicts: # src/platform/plugins/shared/discover/public/application/main/components/top_nav/discover_topnav.tsx
- Resolves elastic#246896 ## Summary This PR makes sure that the latest query draft is captured and restored when switching tabs. The issue was hidden in UnifiedSearch because it was listening to the global services changes (query, filters, refresh interval) instead of simply using the passed props. This was creating inconsistency between the controlled by Discover props and the controlled by Unified Search props. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels. (cherry picked from commit 4930dae) # Conflicts: # src/platform/plugins/shared/discover/public/application/main/components/top_nav/discover_topnav.tsx
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
) # Backport This will backport the following commits from `main` to `9.2`: - [[Discover] Fix query drafts when switching tabs (#247968)](#247968) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2026-01-13T16:51:23Z","message":"[Discover] Fix query drafts when switching tabs (#247968)\n\n- Resolves https://github.com/elastic/kibana/issues/246896\n\n## Summary\n\nThis PR makes sure that the latest query draft is captured and restored\nwhen switching tabs. The issue was hidden in UnifiedSearch because it\nwas listening to the global services changes (query, filters, refresh\ninterval) instead of simply using the passed props. This was creating\ninconsistency between the controlled by Discover props and the\ncontrolled by Unified Search props.\n\n\n### Checklist\n\n- [x] [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- [x] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"4930daea2f8e10d6d05325f2e21c9c086d675113","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:version","v9.3.0","v9.4.0","v9.2.5"],"title":"[Discover] Fix query drafts when switching tabs","number":247968,"url":"https://github.com/elastic/kibana/pull/247968","mergeCommit":{"message":"[Discover] Fix query drafts when switching tabs (#247968)\n\n- Resolves https://github.com/elastic/kibana/issues/246896\n\n## Summary\n\nThis PR makes sure that the latest query draft is captured and restored\nwhen switching tabs. The issue was hidden in UnifiedSearch because it\nwas listening to the global services changes (query, filters, refresh\ninterval) instead of simply using the passed props. This was creating\ninconsistency between the controlled by Discover props and the\ncontrolled by Unified Search props.\n\n\n### Checklist\n\n- [x] [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- [x] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"4930daea2f8e10d6d05325f2e21c9c086d675113"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/247968","number":247968,"mergeCommit":{"message":"[Discover] Fix query drafts when switching tabs (#247968)\n\n- Resolves https://github.com/elastic/kibana/issues/246896\n\n## Summary\n\nThis PR makes sure that the latest query draft is captured and restored\nwhen switching tabs. The issue was hidden in UnifiedSearch because it\nwas listening to the global services changes (query, filters, refresh\ninterval) instead of simply using the passed props. This was creating\ninconsistency between the controlled by Discover props and the\ncontrolled by Unified Search props.\n\n\n### Checklist\n\n- [x] [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- [x] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"4930daea2f8e10d6d05325f2e21c9c086d675113"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
) # Backport This will backport the following commits from `main` to `9.3`: - [[Discover] Fix query drafts when switching tabs (#247968)](#247968) <!--- Backport version: 10.2.0 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Julia Rechkunova","email":"julia.rechkunova@elastic.co"},"sourceCommit":{"committedDate":"2026-01-13T16:51:23Z","message":"[Discover] Fix query drafts when switching tabs (#247968)\n\n- Resolves https://github.com/elastic/kibana/issues/246896\n\n## Summary\n\nThis PR makes sure that the latest query draft is captured and restored\nwhen switching tabs. The issue was hidden in UnifiedSearch because it\nwas listening to the global services changes (query, filters, refresh\ninterval) instead of simply using the passed props. This was creating\ninconsistency between the controlled by Discover props and the\ncontrolled by Unified Search props.\n\n\n### Checklist\n\n- [x] [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- [x] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"4930daea2f8e10d6d05325f2e21c9c086d675113","branchLabelMapping":{"^v9.4.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:DataDiscovery","backport:version","v9.3.0","v9.4.0","v9.2.5"],"title":"[Discover] Fix query drafts when switching tabs","number":247968,"url":"https://github.com/elastic/kibana/pull/247968","mergeCommit":{"message":"[Discover] Fix query drafts when switching tabs (#247968)\n\n- Resolves https://github.com/elastic/kibana/issues/246896\n\n## Summary\n\nThis PR makes sure that the latest query draft is captured and restored\nwhen switching tabs. The issue was hidden in UnifiedSearch because it\nwas listening to the global services changes (query, filters, refresh\ninterval) instead of simply using the passed props. This was creating\ninconsistency between the controlled by Discover props and the\ncontrolled by Unified Search props.\n\n\n### Checklist\n\n- [x] [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- [x] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"4930daea2f8e10d6d05325f2e21c9c086d675113"}},"sourceBranch":"main","suggestedTargetBranches":["9.3","9.2"],"targetPullRequestStates":[{"branch":"9.3","label":"v9.3.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v9.4.0","branchLabelMappingKey":"^v9.4.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/247968","number":247968,"mergeCommit":{"message":"[Discover] Fix query drafts when switching tabs (#247968)\n\n- Resolves https://github.com/elastic/kibana/issues/246896\n\n## Summary\n\nThis PR makes sure that the latest query draft is captured and restored\nwhen switching tabs. The issue was hidden in UnifiedSearch because it\nwas listening to the global services changes (query, filters, refresh\ninterval) instead of simply using the passed props. This was creating\ninconsistency between the controlled by Discover props and the\ncontrolled by Unified Search props.\n\n\n### Checklist\n\n- [x] [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- [x] 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- [x] Review the [backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand apply applicable `backport:*` labels.","sha":"4930daea2f8e10d6d05325f2e21c9c086d675113"}},{"branch":"9.2","label":"v9.2.5","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
- Resolves elastic#246896 ## Summary This PR makes sure that the latest query draft is captured and restored when switching tabs. The issue was hidden in UnifiedSearch because it was listening to the global services changes (query, filters, refresh interval) instead of simply using the passed props. This was creating inconsistency between the controlled by Discover props and the controlled by Unified Search props. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) - [x] Review the [backport guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing) and apply applicable `backport:*` labels.
Summary
This PR makes sure that the latest query draft is captured and restored when switching tabs. The issue was hidden in UnifiedSearch because it was listening to the global services changes (query, filters, refresh interval) instead of simply using the passed props. This was creating inconsistency between the controlled by Discover props and the controlled by Unified Search props.
Checklist
release_note:*label is applied per the guidelinesbackport:*labels.