-
Notifications
You must be signed in to change notification settings - Fork 8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls #179485
[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls #179485
Conversation
/ci |
/ci |
/ci |
54b01b5
to
dce759a
Compare
/ci |
Pinging @elastic/kibana-presentation (Team:Presentation) |
💚 Build Succeeded
Metrics [docs]Async chunks
History
To update your PR or re-run it, just comment with: cc @Heenawter |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice clean fix! I tested this out locally in chrome and looked through the code. Everything looks solid!
💔 All backports failed
Manual backportTo create the backport manually run:
Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…has no controls (elastic#179485) Closes elastic#179391 ## Summary We were previously only calling `setSavedState` for the control group on dashboard navigation **when the control group was defined in the loaded dashboard** - however, if either the source or destination dashboard had zero controls, this caused problems on navigation: - If the source dashboard had at least one control and the destination dashboard had zero, the destination dashboard's control group `lastSavedInput` would **not** get set in `navigateToDashboard` since it is undefined - i.e. the `lastSavedInput` on the destination dashboard's control group would **still be equal to** the `lastSavedInput` of the source dashboard's control group after navigation. Therefore, hitting "reset" would replace the destination dashboard's empty control group with the source's control group. - If the source dashboard had zero controls and the destination dashboard had at least one, the first step in navigation would work as expected - the `lastSavedInput` of the destination dashboard would be set appropriately. However, upon hitting the browser back button and triggering `navigateToDashboard` a second time, the source dashboard's control group's `lastSavedInput` would **not** get set properly (since it is undefined) and would therefore still be equal to the `lastSavedInput` of the destination dashboard. Therefore, hitting "reset" would replace the source's empty control group with the destination dashboard's controls. This fixes the above scenarios by calling `setSavedState` on the control group **even if** the last saved control group state is undefined. ### Race Condition Fix In my testing for this, I discovered **another** bug caused by a race condition where, on dashboard navigation, the subscription to the control group's `initialize$` subject was firing with the **wrong** input, so the `lastSavedFilters` would be calculated incorrectly. This caused the dashboard to get stuck in an unsaved changes state, like so: https://github.com/elastic/kibana/assets/8698078/14c553a9-21b3-40d0-96ac-0282e9e66911 I fixed this by removing this subscription (it was messy anyway 🙈) and replaced this logic with individual calls to `calculateFiltersFromSelections` - this should be easier to follow, and we ensure that we are **always** doing this calculation with the expected input. Since we aren't `awaiting` these calculations, it also shouldn't slow down the control group's initialization (which was the original reason for using a subscription). ### Checklist - [x] This was checked for [cross-browser compatibility](https://www.elastic.co/support/matrix#matrix_browsers) - [x] Flaky test runner - https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5583 <br/> ![image](https://github.com/elastic/kibana/assets/8698078/cd8ce150-6104-4395-b70c-7309185cc04d) ### For maintainers - [ ] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) (cherry picked from commit 507f09d) # Conflicts: # src/plugins/controls/public/control_group/embeddable/control_group_container.tsx
…hboard has no controls (#179485) (#179842) # Backport This will backport the following commits from `main` to `8.13`: - [[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)](#179485) **Note:** This only fixes the "no controls" bug - the race condition also fixed in that PR does not need to be backported, since the code that caused it was not merged in 8.13. <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Hannah Mudge","email":"Heenawter@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-04-02T14:10:53Z","message":"[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)\n\nCloses #179391 Summary\r\n\r\nWe were previously only calling `setSavedState` for the control group on\r\ndashboard navigation **when the control group was defined in the loaded\r\ndashboard** - however, if either the source or destination dashboard had\r\nzero controls, this caused problems on navigation:\r\n- If the source dashboard had at least one control and the destination\r\ndashboard had zero, the destination dashboard's control group\r\n`lastSavedInput` would **not** get set in `navigateToDashboard` since it\r\nis undefined - i.e. the `lastSavedInput` on the destination dashboard's\r\ncontrol group would **still be equal to** the `lastSavedInput` of the\r\nsource dashboard's control group after navigation. Therefore, hitting\r\n\"reset\" would replace the destination dashboard's empty control group\r\nwith the source's control group.\r\n- If the source dashboard had zero controls and the destination\r\ndashboard had at least one, the first step in navigation would work as\r\nexpected - the `lastSavedInput` of the destination dashboard would be\r\nset appropriately. However, upon hitting the browser back button and\r\ntriggering `navigateToDashboard` a second time, the source dashboard's\r\ncontrol group's `lastSavedInput` would **not** get set properly (since\r\nit is undefined) and would therefore still be equal to the\r\n`lastSavedInput` of the destination dashboard. Therefore, hitting\r\n\"reset\" would replace the source's empty control group with the\r\ndestination dashboard's controls.\r\n\r\nThis fixes the above scenarios by calling `setSavedState` on the control\r\ngroup **even if** the last saved control group state is undefined.\r\n\r\n### Race Condition Fix\r\n\r\nIn my testing for this, I discovered **another** bug caused by a race\r\ncondition where, on dashboard navigation, the subscription to the\r\ncontrol group's `initialize# Backport This will backport the following commits from `main` to `8.13`: - [[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)](#179485) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT subject was firing with the **wrong**\r\ninput, so the `lastSavedFilters` would be calculated incorrectly. This\r\ncaused the dashboard to get stuck in an unsaved changes state, like so:\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/14c553a9-21b3-40d0-96ac-0282e9e66911\r\n\r\n\r\n\r\nI fixed this by removing this subscription (it was messy anyway 🙈) and\r\nreplaced this logic with individual calls to\r\n`calculateFiltersFromSelections` - this should be easier to follow, and\r\nwe ensure that we are **always** doing this calculation with the\r\nexpected input. Since we aren't `awaiting` these calculations, it also\r\nshouldn't slow down the control group's initialization (which was the\r\noriginal reason for using a subscription).\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n- [x] Flaky test runner -\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5583\r\n<br/>\r\n\r\n![image](https://github.com/elastic/kibana/assets/8698078/cd8ce150-6104-4395-b70c-7309185cc04d)\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"507f09d0b69a99f03f0c0cb19f10f1ea8584cd47","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Presentation","loe:small","impact:high","backport:prev-minor","v8.14.0"],"number":179485,"url":"https://github.com/elastic/kibana/pull/179485","mergeCommit":{"message":"[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)\n\nCloses #179391 Summary\r\n\r\nWe were previously only calling `setSavedState` for the control group on\r\ndashboard navigation **when the control group was defined in the loaded\r\ndashboard** - however, if either the source or destination dashboard had\r\nzero controls, this caused problems on navigation:\r\n- If the source dashboard had at least one control and the destination\r\ndashboard had zero, the destination dashboard's control group\r\n`lastSavedInput` would **not** get set in `navigateToDashboard` since it\r\nis undefined - i.e. the `lastSavedInput` on the destination dashboard's\r\ncontrol group would **still be equal to** the `lastSavedInput` of the\r\nsource dashboard's control group after navigation. Therefore, hitting\r\n\"reset\" would replace the destination dashboard's empty control group\r\nwith the source's control group.\r\n- If the source dashboard had zero controls and the destination\r\ndashboard had at least one, the first step in navigation would work as\r\nexpected - the `lastSavedInput` of the destination dashboard would be\r\nset appropriately. However, upon hitting the browser back button and\r\ntriggering `navigateToDashboard` a second time, the source dashboard's\r\ncontrol group's `lastSavedInput` would **not** get set properly (since\r\nit is undefined) and would therefore still be equal to the\r\n`lastSavedInput` of the destination dashboard. Therefore, hitting\r\n\"reset\" would replace the source's empty control group with the\r\ndestination dashboard's controls.\r\n\r\nThis fixes the above scenarios by calling `setSavedState` on the control\r\ngroup **even if** the last saved control group state is undefined.\r\n\r\n### Race Condition Fix\r\n\r\nIn my testing for this, I discovered **another** bug caused by a race\r\ncondition where, on dashboard navigation, the subscription to the\r\ncontrol group's `initialize# Backport This will backport the following commits from `main` to `8.13`: - [[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)](#179485) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT subject was firing with the **wrong**\r\ninput, so the `lastSavedFilters` would be calculated incorrectly. This\r\ncaused the dashboard to get stuck in an unsaved changes state, like so:\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/14c553a9-21b3-40d0-96ac-0282e9e66911\r\n\r\n\r\n\r\nI fixed this by removing this subscription (it was messy anyway 🙈) and\r\nreplaced this logic with individual calls to\r\n`calculateFiltersFromSelections` - this should be easier to follow, and\r\nwe ensure that we are **always** doing this calculation with the\r\nexpected input. Since we aren't `awaiting` these calculations, it also\r\nshouldn't slow down the control group's initialization (which was the\r\noriginal reason for using a subscription).\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n- [x] Flaky test runner -\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5583\r\n<br/>\r\n\r\n![image](https://github.com/elastic/kibana/assets/8698078/cd8ce150-6104-4395-b70c-7309185cc04d)\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"507f09d0b69a99f03f0c0cb19f10f1ea8584cd47"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","labelRegex":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/179485","number":179485,"mergeCommit":{"message":"[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)\n\nCloses #179391 Summary\r\n\r\nWe were previously only calling `setSavedState` for the control group on\r\ndashboard navigation **when the control group was defined in the loaded\r\ndashboard** - however, if either the source or destination dashboard had\r\nzero controls, this caused problems on navigation:\r\n- If the source dashboard had at least one control and the destination\r\ndashboard had zero, the destination dashboard's control group\r\n`lastSavedInput` would **not** get set in `navigateToDashboard` since it\r\nis undefined - i.e. the `lastSavedInput` on the destination dashboard's\r\ncontrol group would **still be equal to** the `lastSavedInput` of the\r\nsource dashboard's control group after navigation. Therefore, hitting\r\n\"reset\" would replace the destination dashboard's empty control group\r\nwith the source's control group.\r\n- If the source dashboard had zero controls and the destination\r\ndashboard had at least one, the first step in navigation would work as\r\nexpected - the `lastSavedInput` of the destination dashboard would be\r\nset appropriately. However, upon hitting the browser back button and\r\ntriggering `navigateToDashboard` a second time, the source dashboard's\r\ncontrol group's `lastSavedInput` would **not** get set properly (since\r\nit is undefined) and would therefore still be equal to the\r\n`lastSavedInput` of the destination dashboard. Therefore, hitting\r\n\"reset\" would replace the source's empty control group with the\r\ndestination dashboard's controls.\r\n\r\nThis fixes the above scenarios by calling `setSavedState` on the control\r\ngroup **even if** the last saved control group state is undefined.\r\n\r\n### Race Condition Fix\r\n\r\nIn my testing for this, I discovered **another** bug caused by a race\r\ncondition where, on dashboard navigation, the subscription to the\r\ncontrol group's `initialize# Backport This will backport the following commits from `main` to `8.13`: - [[Dashboard] [Controls] Fix bug with drilldowns when source dashboard has no controls (#179485)](#179485) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT subject was firing with the **wrong**\r\ninput, so the `lastSavedFilters` would be calculated incorrectly. This\r\ncaused the dashboard to get stuck in an unsaved changes state, like so:\r\n\r\n\r\n\r\nhttps://github.com/elastic/kibana/assets/8698078/14c553a9-21b3-40d0-96ac-0282e9e66911\r\n\r\n\r\n\r\nI fixed this by removing this subscription (it was messy anyway 🙈) and\r\nreplaced this logic with individual calls to\r\n`calculateFiltersFromSelections` - this should be easier to follow, and\r\nwe ensure that we are **always** doing this calculation with the\r\nexpected input. Since we aren't `awaiting` these calculations, it also\r\nshouldn't slow down the control group's initialization (which was the\r\noriginal reason for using a subscription).\r\n\r\n\r\n### Checklist\r\n\r\n\r\n- [x] This was checked for [cross-browser\r\ncompatibility](https://www.elastic.co/support/matrix#matrix_browsers)\r\n- [x] Flaky test runner -\r\nhttps://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/5583\r\n<br/>\r\n\r\n![image](https://github.com/elastic/kibana/assets/8698078/cd8ce150-6104-4395-b70c-7309185cc04d)\r\n\r\n\r\n### For maintainers\r\n\r\n- [ ] This was checked for breaking API changes and was [labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)","sha":"507f09d0b69a99f03f0c0cb19f10f1ea8584cd47"}}]}] BACKPORT-->
Closes #179391
Summary
We were previously only calling
setSavedState
for the control group on dashboard navigation when the control group was defined in the loaded dashboard - however, if either the source or destination dashboard had zero controls, this caused problems on navigation:lastSavedInput
would not get set innavigateToDashboard
since it is undefined - i.e. thelastSavedInput
on the destination dashboard's control group would still be equal to thelastSavedInput
of the source dashboard's control group after navigation. Therefore, hitting "reset" would replace the destination dashboard's empty control group with the source's control group.lastSavedInput
of the destination dashboard would be set appropriately. However, upon hitting the browser back button and triggeringnavigateToDashboard
a second time, the source dashboard's control group'slastSavedInput
would not get set properly (since it is undefined) and would therefore still be equal to thelastSavedInput
of the destination dashboard. Therefore, hitting "reset" would replace the source's empty control group with the destination dashboard's controls.This fixes the above scenarios by calling
setSavedState
on the control group even if the last saved control group state is undefined.Race Condition Fix
In my testing for this, I discovered another bug caused by a race condition where, on dashboard navigation, the subscription to the control group's
initialize$
subject was firing with the wrong input, so thelastSavedFilters
would be calculated incorrectly. This caused the dashboard to get stuck in an unsaved changes state, like so:Screen.Recording.2024-03-26.at.4.19.57.PM.mov
I fixed this by removing this subscription (it was messy anyway 🙈) and replaced this logic with individual calls to
calculateFiltersFromSelections
- this should be easier to follow, and we ensure that we are always doing this calculation with the expected input. Since we aren'tawaiting
these calculations, it also shouldn't slow down the control group's initialization (which was the original reason for using a subscription).Checklist
For maintainers