-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Embeddable] Avoid rerendering loop due to search context reload (#20…
…3150) ## Summary Fixes #202266 This PR fixes the underline rerendering issue at the `useSearchApi` hook level, so any embeddable component who uses this hook would benefit from the fix. Ideally the props passed to the Lens component should be memoized, but this assumption would break many integrations as the previous embeddable component did take care of filtering duplicates. To test this: * Go to `Observability > Alerts > Manage rules` and `Add Rule`, pick the `Custom threshold` option and verify the infinite reload does not happen Once fixed this, another problem bubbled up with the brushing use case: when brushing a chart the chart was always one time range step behind. The other bug was due to the `fetch$(api)` function propagating a stale `data` search context who the Lens embeddable was relying on. To solve this other problem the following changes have been applied: * read the `searchSessionId` from the `api` directly (used for `autoRefresh`) * make sure to test the `Refresh` feature with both relative and absolute time ranges * read the `search context` from the `parentApi` directly if implements the `unifiedSearch` API * to test this, brush and check that the final time range matches the correct time range **Note**: the fundamental issue for the latter is `fetch$` not emitting the up-to-date `data` when the parentApi search context updates. The retrieved `data` is stale and one step behind, so it is not reliable. cc @elastic/kibana-presentation As @ThomThomson noticed in his test failure investigation another issue was found in this PR due to the wrong handling of the searchSessionId within the Observability page (for more details see [his analysis](#203150 (comment))). @markov00 and @crespocarlos helped risolve this problem with some additional changes on the Observability side of things: this will lead to some extra searchSessionId to be created, which will be eventually solved by Observability team [shortly moving away from the `searchSessionId` mechanism](#203412) ### 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 --------- Co-authored-by: Marco Vettorello <[email protected]> Co-authored-by: Carlos Crespo <[email protected]>
- Loading branch information
1 parent
c1addc9
commit d4194ba
Showing
10 changed files
with
192 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.