Skip to content

[Discover] Use the current search draft when saving a search WIP#19

Draft
jughosta wants to merge 1 commit into218509-restore-search-statefrom
189900-start-using-search-draft
Draft

[Discover] Use the current search draft when saving a search WIP#19
jughosta wants to merge 1 commit into218509-restore-search-statefrom
189900-start-using-search-draft

Conversation

@jughosta
Copy link
Copy Markdown
Owner

@jughosta jughosta commented Jul 15, 2025

Summary

Use searchDraft when saving a search or when transitioning from Classic mode to ES|QL mode.

Checklist

Delete any items that are not applicable to this PR.

Risk Matrix

Delete this section if it is not applicable to this PR.

Before closing this PR, invite QA, stakeholders, and other developers to identify risks that should be tested prior to the change/feature release.

When forming the risk matrix, consider some of the following examples and how they may potentially impact the change:

Risk Probability Severity Mitigation/Notes
Multiple Spaces—unexpected behavior in non-default Kibana Space. Low High Integration tests will verify that all features are still supported in non-default Kibana Space and when user switches between spaces.
Multiple nodes—Elasticsearch polling might have race conditions when multiple Kibana nodes are polling for the same tasks. High Low Tasks are idempotent, so executing them multiple times will not result in logical error, but will degrade performance. To test for this case we add plenty of unit tests around this logic and document manual testing procedure.
Code should gracefully handle cases when feature X or plugin Y are disabled. Medium High Unit tests will verify that any feature flag or plugin combination still results in our service operational.
See more potential risk examples

For maintainers

jughosta added a commit to elastic/kibana that referenced this pull request Jul 22, 2025
… range) (#227298)

- Addresses #218509

## Summary

This PR introduces a way to keep track of the unsubmitted changes in
UnifiedSearch component (`query`, `dateRangeFrom` and `dateRangeTo`) and
restores when when switching tabs in Discover. It does not use
`@kbn/restorable-state` because
`src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx`
is a class component which would require a lot of refactoring otherwise.
Instead, the PR introduces `draft` and `onDraftChange` optional props
for UnifiedSearch. They allow to mount a search bar with a prefilled
query state and it will be visually rendered as "dirty" (with "Update"
button).

- [x] unsubmitted KQL query and unsubmitted time range
- [x] unsubmitted ES|QL query and unsubmitted time range

Saving `uiState.searchDraft` per tab will allow us to address other
issues too jughosta#19.

### Testing

To enable tabs in Discover, run
`localStorage.setItem('discoverExperimental:tabs', 'true')` in browser
Console.

### 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] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Bluefinger pushed a commit to Bluefinger/kibana that referenced this pull request Jul 22, 2025
… range) (elastic#227298)

- Addresses elastic#218509

## Summary

This PR introduces a way to keep track of the unsubmitted changes in
UnifiedSearch component (`query`, `dateRangeFrom` and `dateRangeTo`) and
restores when when switching tabs in Discover. It does not use
`@kbn/restorable-state` because
`src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx`
is a class component which would require a lot of refactoring otherwise.
Instead, the PR introduces `draft` and `onDraftChange` optional props
for UnifiedSearch. They allow to mount a search bar with a prefilled
query state and it will be visually rendered as "dirty" (with "Update"
button).

- [x] unsubmitted KQL query and unsubmitted time range
- [x] unsubmitted ES|QL query and unsubmitted time range

Saving `uiState.searchDraft` per tab will allow us to address other
issues too jughosta#19.

### Testing

To enable tabs in Discover, run
`localStorage.setItem('discoverExperimental:tabs', 'true')` in browser
Console.

### 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] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
maxcold pushed a commit to elastic/kibana that referenced this pull request Jul 22, 2025
… range) (#227298)

- Addresses #218509

## Summary

This PR introduces a way to keep track of the unsubmitted changes in
UnifiedSearch component (`query`, `dateRangeFrom` and `dateRangeTo`) and
restores when when switching tabs in Discover. It does not use
`@kbn/restorable-state` because
`src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx`
is a class component which would require a lot of refactoring otherwise.
Instead, the PR introduces `draft` and `onDraftChange` optional props
for UnifiedSearch. They allow to mount a search bar with a prefilled
query state and it will be visually rendered as "dirty" (with "Update"
button).

- [x] unsubmitted KQL query and unsubmitted time range
- [x] unsubmitted ES|QL query and unsubmitted time range

Saving `uiState.searchDraft` per tab will allow us to address other
issues too jughosta#19.

### Testing

To enable tabs in Discover, run
`localStorage.setItem('discoverExperimental:tabs', 'true')` in browser
Console.

### 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] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
kdelemme pushed a commit to kdelemme/kibana that referenced this pull request Jul 23, 2025
… range) (elastic#227298)

- Addresses elastic#218509

## Summary

This PR introduces a way to keep track of the unsubmitted changes in
UnifiedSearch component (`query`, `dateRangeFrom` and `dateRangeTo`) and
restores when when switching tabs in Discover. It does not use
`@kbn/restorable-state` because
`src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx`
is a class component which would require a lot of refactoring otherwise.
Instead, the PR introduces `draft` and `onDraftChange` optional props
for UnifiedSearch. They allow to mount a search bar with a prefilled
query state and it will be visually rendered as "dirty" (with "Update"
button).

- [x] unsubmitted KQL query and unsubmitted time range
- [x] unsubmitted ES|QL query and unsubmitted time range

Saving `uiState.searchDraft` per tab will allow us to address other
issues too jughosta#19.

### Testing

To enable tabs in Discover, run
`localStorage.setItem('discoverExperimental:tabs', 'true')` in browser
Console.

### 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] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
kertal pushed a commit to kertal/kibana that referenced this pull request Jul 25, 2025
… range) (elastic#227298)

- Addresses elastic#218509

## Summary

This PR introduces a way to keep track of the unsubmitted changes in
UnifiedSearch component (`query`, `dateRangeFrom` and `dateRangeTo`) and
restores when when switching tabs in Discover. It does not use
`@kbn/restorable-state` because
`src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx`
is a class component which would require a lot of refactoring otherwise.
Instead, the PR introduces `draft` and `onDraftChange` optional props
for UnifiedSearch. They allow to mount a search bar with a prefilled
query state and it will be visually rendered as "dirty" (with "Update"
button).

- [x] unsubmitted KQL query and unsubmitted time range
- [x] unsubmitted ES|QL query and unsubmitted time range

Saving `uiState.searchDraft` per tab will allow us to address other
issues too jughosta#19.

### Testing

To enable tabs in Discover, run
`localStorage.setItem('discoverExperimental:tabs', 'true')` in browser
Console.

### 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] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
crespocarlos pushed a commit to crespocarlos/kibana that referenced this pull request Jul 25, 2025
… range) (elastic#227298)

- Addresses elastic#218509

## Summary

This PR introduces a way to keep track of the unsubmitted changes in
UnifiedSearch component (`query`, `dateRangeFrom` and `dateRangeTo`) and
restores when when switching tabs in Discover. It does not use
`@kbn/restorable-state` because
`src/platform/plugins/shared/unified_search/public/search_bar/search_bar.tsx`
is a class component which would require a lot of refactoring otherwise.
Instead, the PR introduces `draft` and `onDraftChange` optional props
for UnifiedSearch. They allow to mount a search bar with a prefilled
query state and it will be visually rendered as "dirty" (with "Update"
button).

- [x] unsubmitted KQL query and unsubmitted time range
- [x] unsubmitted ES|QL query and unsubmitted time range

Saving `uiState.searchDraft` per tab will allow us to address other
issues too jughosta#19.

### Testing

To enable tabs in Discover, run
`localStorage.setItem('discoverExperimental:tabs', 'true')` in browser
Console.

### 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] [Flaky Test
Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was
used on any tests changed
- [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.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant