[canvas] fix by-value map embeddables have broken layers (#190996)

Resolves https://github.com/elastic/kibana/issues/190994

### Test instructions
1. create new canvas workpad
2. Click "Select type" and select "Maps"
3. Add a documents layer to your map and click "Save and return"
4. Click "canvas" bread crumb to go back to canvas listing page
5. Open you work pad again. Map should still display data
This commit is contained in:
Nathan Reese 2024-08-21 11:19:35 -06:00 committed by GitHub
parent 0ffd37a074
commit 1da096793d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 0 deletions

View file

@ -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`

View file

@ -11,6 +11,7 @@ import { EmbeddableInput as Input } from '@kbn/embeddable-plugin/common';
import type {
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<HasAppContext & PublishesUnifiedSearch>;

View file

@ -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(),