Skip to content

Commit 7088fa9

Browse files
kibanamachineCorey Robertson
andauthored
[Canvas] Fix reports embeddables (#93482) (#93679)
* wip * WIP Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Corey Robertson <corey.robertson@elastic.co>
1 parent 961af39 commit 7088fa9

File tree

1 file changed

+16
-4
lines changed
  • x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable

1 file changed

+16
-4
lines changed

x-pack/plugins/canvas/canvas_plugin_src/renderers/embeddable/embeddable.tsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { CANVAS_EMBEDDABLE_CLASSNAME } from '../../../common/lib';
2424
const { embeddable: strings } = RendererStrings;
2525

2626
const embeddablesRegistry: {
27-
[key: string]: IEmbeddable;
27+
[key: string]: IEmbeddable | Promise<IEmbeddable>;
2828
} = {};
2929

3030
const renderEmbeddableFactory = (core: CoreStart, plugins: StartDeps) => {
@@ -67,7 +67,15 @@ export const embeddableRendererFactory = (
6767
throw new EmbeddableFactoryNotFoundError(embeddableType);
6868
}
6969

70-
const embeddableObject = await factory.createFromSavedObject(input.id, input);
70+
const embeddablePromise = factory
71+
.createFromSavedObject(input.id, input)
72+
.then((embeddable) => {
73+
embeddablesRegistry[uniqueId] = embeddable;
74+
return embeddable;
75+
});
76+
embeddablesRegistry[uniqueId] = embeddablePromise;
77+
78+
const embeddableObject = await (async () => embeddablePromise)();
7179

7280
const palettes = await plugins.charts.palettes.getPalettes();
7381

@@ -105,8 +113,12 @@ export const embeddableRendererFactory = (
105113
return ReactDOM.unmountComponentAtNode(domNode);
106114
});
107115
} else {
108-
embeddablesRegistry[uniqueId].updateInput(input);
109-
embeddablesRegistry[uniqueId].reload();
116+
const embeddable = embeddablesRegistry[uniqueId];
117+
118+
if ('updateInput' in embeddable) {
119+
embeddable.updateInput(input);
120+
embeddable.reload();
121+
}
110122
}
111123
},
112124
});

0 commit comments

Comments
 (0)