Skip to content

[Discover] Fix query drafts when switching tabs#247968

Merged
jughosta merged 21 commits intoelastic:mainfrom
jughosta:246896-fix-tab-query-drafts
Jan 13, 2026
Merged

[Discover] Fix query drafts when switching tabs#247968
jughosta merged 21 commits intoelastic:mainfrom
jughosta:246896-fix-tab-query-drafts

Conversation

@jughosta
Copy link
Contributor

@jughosta jughosta commented Jan 6, 2026

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

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.
@jughosta jughosta self-assigned this Jan 6, 2026
@jughosta jughosta added release_note:skip Skip the PR/issue when compiling release notes Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// backport:version Backport to applied version labels v9.3.0 v9.2.4 labels Jan 6, 2026
filterManager: data.query.filterManager,
});
const { query } = useQueryStringManager({
disabled: disableSubscribingToGlobalDataServices,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just minimizing the number of updates.

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@jughosta jughosta added release_note:fix and removed release_note:skip Skip the PR/issue when compiling release notes labels Jan 9, 2026
@jughosta jughosta added v9.2.5 and removed v9.2.4 labels Jan 12, 2026
@jughosta jughosta marked this pull request as ready for review January 12, 2026 17:44
@jughosta jughosta requested review from a team as code owners January 12, 2026 17:45
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-data-discovery (Team:DataDiscovery)

Copy link
Contributor

@ThomThomson ThomThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unified search drafts functionality changes LGTM. Code review only

Copy link
Contributor

@davismcphee davismcphee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did another round of review and testing, and it's working well, thanks for fixing it!

@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
discover 1.4MB 1.4MB +544.0B
unifiedSearch 401.3KB 401.5KB +182.0B
total +726.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
unifiedSearch 22.8KB 23.7KB +872.0B

History

cc @jughosta

@jughosta jughosta merged commit 4930dae into elastic:main Jan 13, 2026
13 checks passed
@jughosta jughosta deleted the 246896-fix-tab-query-drafts branch January 13, 2026 16:51
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 9.2, 9.3

https://github.com/elastic/kibana/actions/runs/20965109287

@kibanamachine
Copy link
Contributor

💔 All backports failed

Status Branch Result
9.2 Backport failed because of merge conflicts
9.3 Backport failed because of merge conflicts

Manual backport

To create the backport manually run:

node scripts/backport --pr 247968

Questions ?

Please refer to the Backport tool documentation

jughosta added a commit to jughosta/kibana that referenced this pull request Jan 13, 2026
- 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
jughosta added a commit to jughosta/kibana that referenced this pull request Jan 13, 2026
- 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
@jughosta
Copy link
Contributor Author

💚 All backports created successfully

Status Branch Result
9.3
9.2

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

jughosta added a commit that referenced this pull request Jan 14, 2026
)

# 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-->
jughosta added a commit that referenced this pull request Jan 14, 2026
)

# 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-->
smith pushed a commit to smith/kibana that referenced this pull request Jan 16, 2026
- 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport:version Backport to applied version labels release_note:fix Team:DataDiscovery Discover, search (data plugin and KQL), data views, saved searches. For ES|QL, use Team:ES|QL. t// v9.2.4 v9.2.5 v9.3.0 v9.4.0

6 participants