kibana/src
Devon Thomson 049c51093b
[Dashboard] fix custom time ranges not applied to panel until global query context changes (#155458)
Fixes https://github.com/elastic/kibana/issues/155409

https://github.com/elastic/kibana/pull/152516 incorrectly attempted to
resolve https://github.com/elastic/kibana/issues/151221.
https://github.com/elastic/kibana/pull/152516 updated shouldFetch$ to
only check searchSessionId to determine if re-fetching is required. This
logic did not work when custom time ranges are applied to panels since
custom time ranges do not require new search session id yet the time
range changed.

This PR reverts shouldFetch$ logic of only checking searchSessionId to
determine if re-fetching is required.

Instead, this PR moves searchSessionId out of input and into dashboard
instance state. That way, `input` updates, such as query, do not trigger
additional `input` updates. The PR also updates seachSessionId logic
from async to sync so that dashboard can update seachSessionId on input
changes prior to child embeddables updating to parent input changes.
This avoids the double fetch and allows children to only have a single
input update on query state change.

There was a functional test, panel_time_range, that should have caught
the regression but that test had a bug in it. The assertion that the
custom time range was applied looked like `expect(await
testSubjects.exists('emptyPlaceholder'))` which will never fail the test
because the last part of the expect is missing. Instead, the statements
should be `expect(await
testSubjects.exists('emptyPlaceholder')).to.be(true)`. These updates to
the functional test would have caught the regression (I verified this by
making these changes on main and running the test. They do indeed fail).

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: nreese <reese.nathan@elastic.co>
2023-04-26 07:02:59 -06:00
..
cli Setup Node.js environment before instrumenting Kibana with APM. (#155063) 2023-04-19 18:33:11 +02:00
cli_encryption_keys Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
cli_health_gateway Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
cli_keystore Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
cli_plugin Remove a unnecessary argument (#150268) 2023-02-07 08:58:10 -06:00
cli_setup [Elasticsearch] Log queued requests (#152571) 2023-03-06 14:25:44 +01:00
cli_verification_code Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00
core Moving all possible fields from mappings to schemas in the Spaces SO type (#155541) 2023-04-25 17:54:52 -04:00
dev [SecuritySolution] Refactor security packages (#155365) 2023-04-26 05:05:36 -07:00
plugins [Dashboard] fix custom time ranges not applied to panel until global query context changes (#155458) 2023-04-26 07:02:59 -06:00
setup_node_env Transpile packages on demand, validate all TS projects (#146212) 2022-12-22 19:00:29 -06:00