Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[8.13] [dashboard] fix console error "Panel not found" when…
… linking or unlinking panel to library (#178464) (#178590) # Backport This will backport the following commits from `main` to `8.13`: - [[dashboard] fix console error "Panel not found" when linking or unlinking panel to library (#178464)](#178464) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Nathan Reese","email":"reese.nathan@elastic.co"},"sourceCommit":{"committedDate":"2024-03-13T01:00:04Z","message":"[dashboard] fix console error \"Panel not found\" when linking or unlinking panel to library (#178464)\n\ncloses https://github.com/elastic/kibana/issues/178442\r\n\r\nThere is a timing issue in `getComponentFromEmbeddable`.\r\n1. `EmbeddablePanel` calls `getComponentFromEmbeddable`.\r\n2. First `getComponentFromEmbeddable` call starts async operation `await\r\nPromise.all([startServicesPromise, embeddablePromise])`\r\n3. Props for `EmbeddablePanel` get updated because dashboard.panels\r\nchanges. `EmbeddablePanel` calls `getComponentFromEmbeddable` a second\r\ntime because `props.embeddable` changes.\r\n4. Results of first `getComponentFromEmbeddable` async call return. At\r\nthis point, panels has changed and no longer contains id of old\r\nembeddable, but `getComponentFromEmbeddable` tries to call\r\n`untilEmbeddableLoaded` even though panel no longer exists.\r\n\r\nPR resolves issue by\r\n1. adding isMounted check after async action and returning null if\r\ncomponent is no longer mounted after `startServicesPromise,\r\nembeddablePromise` promises return\r\n2. Syncronizing `EmbeddablePanel` `useMemo` and `PresentationPanel`\r\n`useAsync` dependency chain to ensure they are consistent.\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"49d8083f6e4e35b82708cb3b2ecd60ff20ac3560","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Embedding","Team:Presentation","release_note:skip","v8.13.0","project:embeddableRebuild","v8.14.0"],"title":"[dashboard] fix console error \"Panel not found\" when linking or unlinking panel to library","number":178464,"url":"https://github.com/elastic/kibana/pull/178464","mergeCommit":{"message":"[dashboard] fix console error \"Panel not found\" when linking or unlinking panel to library (#178464)\n\ncloses https://github.com/elastic/kibana/issues/178442\r\n\r\nThere is a timing issue in `getComponentFromEmbeddable`.\r\n1. `EmbeddablePanel` calls `getComponentFromEmbeddable`.\r\n2. First `getComponentFromEmbeddable` call starts async operation `await\r\nPromise.all([startServicesPromise, embeddablePromise])`\r\n3. Props for `EmbeddablePanel` get updated because dashboard.panels\r\nchanges. `EmbeddablePanel` calls `getComponentFromEmbeddable` a second\r\ntime because `props.embeddable` changes.\r\n4. Results of first `getComponentFromEmbeddable` async call return. At\r\nthis point, panels has changed and no longer contains id of old\r\nembeddable, but `getComponentFromEmbeddable` tries to call\r\n`untilEmbeddableLoaded` even though panel no longer exists.\r\n\r\nPR resolves issue by\r\n1. adding isMounted check after async action and returning null if\r\ncomponent is no longer mounted after `startServicesPromise,\r\nembeddablePromise` promises return\r\n2. Syncronizing `EmbeddablePanel` `useMemo` and `PresentationPanel`\r\n`useAsync` dependency chain to ensure they are consistent.\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"49d8083f6e4e35b82708cb3b2ecd60ff20ac3560"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"8.13","label":"v8.13.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/178464","number":178464,"mergeCommit":{"message":"[dashboard] fix console error \"Panel not found\" when linking or unlinking panel to library (#178464)\n\ncloses https://github.com/elastic/kibana/issues/178442\r\n\r\nThere is a timing issue in `getComponentFromEmbeddable`.\r\n1. `EmbeddablePanel` calls `getComponentFromEmbeddable`.\r\n2. First `getComponentFromEmbeddable` call starts async operation `await\r\nPromise.all([startServicesPromise, embeddablePromise])`\r\n3. Props for `EmbeddablePanel` get updated because dashboard.panels\r\nchanges. `EmbeddablePanel` calls `getComponentFromEmbeddable` a second\r\ntime because `props.embeddable` changes.\r\n4. Results of first `getComponentFromEmbeddable` async call return. At\r\nthis point, panels has changed and no longer contains id of old\r\nembeddable, but `getComponentFromEmbeddable` tries to call\r\n`untilEmbeddableLoaded` even though panel no longer exists.\r\n\r\nPR resolves issue by\r\n1. adding isMounted check after async action and returning null if\r\ncomponent is no longer mounted after `startServicesPromise,\r\nembeddablePromise` promises return\r\n2. Syncronizing `EmbeddablePanel` `useMemo` and `PresentationPanel`\r\n`useAsync` dependency chain to ensure they are consistent.\r\n\r\n---------\r\n\r\nCo-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>","sha":"49d8083f6e4e35b82708cb3b2ecd60ff20ac3560"}}]}] BACKPORT--> Co-authored-by: Nathan Reese <reese.nathan@elastic.co>
- Loading branch information