From 0669c37590cecdb51224413de39d8d1a024d8af2 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 22 Aug 2024 04:45:10 +1000 Subject: [PATCH] [8.15] [canvas] fix by-value map embeddables have broken layers (#190996) (#191011) # Backport This will backport the following commits from `main` to `8.15`: - [[canvas] fix by-value map embeddables have broken layers (#190996)](https://github.com/elastic/kibana/pull/190996) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Nathan Reese --- .../canvas/public/components/hooks/use_canvas_api.tsx | 1 + x-pack/plugins/canvas/types/embeddables.ts | 2 ++ .../public/react_embeddable/map_react_embeddable.tsx | 11 +++++++++++ 3 files changed, 14 insertions(+) diff --git a/x-pack/plugins/canvas/public/components/hooks/use_canvas_api.tsx b/x-pack/plugins/canvas/public/components/hooks/use_canvas_api.tsx index 3d1784bf65c82d..fa302c57ead8c6 100644 --- a/x-pack/plugins/canvas/public/components/hooks/use_canvas_api.tsx +++ b/x-pack/plugins/canvas/public/components/hooks/use_canvas_api.tsx @@ -49,6 +49,7 @@ export const useCanvasApi: () => CanvasContainerApi = () => { createNewEmbeddable(panelType, initialState); }, disableTriggers: true, + type: 'canvas', /** * getSerializedStateForChild is left out here because we cannot access the state here. That method * is injected in `x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx` diff --git a/x-pack/plugins/canvas/types/embeddables.ts b/x-pack/plugins/canvas/types/embeddables.ts index 18d85d49b24c3a..4bcbd1ce72e018 100644 --- a/x-pack/plugins/canvas/types/embeddables.ts +++ b/x-pack/plugins/canvas/types/embeddables.ts @@ -11,6 +11,7 @@ import { EmbeddableInput as Input } from '@kbn/embeddable-plugin/common'; import { HasAppContext, HasDisableTriggers, + HasType, PublishesViewMode, PublishesUnifiedSearch, } from '@kbn/presentation-publishing'; @@ -25,5 +26,6 @@ export type EmbeddableInput = Input & { export type CanvasContainerApi = PublishesViewMode & CanAddNewPanel & HasDisableTriggers & + HasType & HasSerializedChildState & Partial; diff --git a/x-pack/plugins/maps/public/react_embeddable/map_react_embeddable.tsx b/x-pack/plugins/maps/public/react_embeddable/map_react_embeddable.tsx index 415e3819cdadb7..28a14592a8c32c 100644 --- a/x-pack/plugins/maps/public/react_embeddable/map_react_embeddable.tsx +++ b/x-pack/plugins/maps/public/react_embeddable/map_react_embeddable.tsx @@ -12,6 +12,7 @@ import { APPLY_FILTER_TRIGGER } from '@kbn/data-plugin/public'; import { ReactEmbeddableFactory, VALUE_CLICK_TRIGGER } from '@kbn/embeddable-plugin/public'; import { EmbeddableStateWithType } from '@kbn/embeddable-plugin/common'; import { + apiIsOfType, areTriggersDisabled, getUnchangingComparator, initializeTimeRange, @@ -125,6 +126,16 @@ export const mapEmbeddableFactory: ReactEmbeddableFactory< }; } + /** + * Canvas by-value embeddables do not support references + */ + if (apiIsOfType(parentApi, 'canvas')) { + return { + rawState: getByValueState(rawState, savedMap.getAttributes()), + references: [], + }; + } + // by-value embeddable const { attributes, references } = extractReferences({ attributes: savedMap.getAttributes(),