From 86d877385d6d9ed1d2b45517282682fc186fe9d5 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 20 Dec 2024 02:31:08 +1100 Subject: [PATCH] [8.x] [Lens][Embeddable] Use reload$ api for custom component (#203755) (#204946) # Backport This will backport the following commits from `main` to `8.x`: - [[Lens][Embeddable] Use reload$ api for custom component (#203755)](https://github.com/elastic/kibana/pull/203755) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Marco Liberati --- .../renderer/lens_custom_renderer_component.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx b/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx index 70d59fc7486b2..3caada55b81db 100644 --- a/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx +++ b/x-pack/plugins/lens/public/react_embeddable/renderer/lens_custom_renderer_component.tsx @@ -61,6 +61,7 @@ export function LensRenderer({ disabledActions, searchSessionId, hidePanelTitles, + lastReloadRequestTime, ...props }: LensRendererProps) { // Use the settings interface to store panel settings @@ -86,6 +87,11 @@ export function LensRenderer({ const showPanelChrome = Boolean(withDefaultActions) || (extraActions?.length || 0) > 0; + const reload$ = useMemo(() => new BehaviorSubject(undefined), []); + useEffect(() => { + reload$.next(); + }, [reload$, lastReloadRequestTime]); + // Re-render on changes // internally the embeddable will evaluate whether it is worth to actual render or not useEffect(() => { @@ -152,6 +158,7 @@ export function LensRenderer({ attributes: props.attributes, }), hidePanelTitle: hidePanelTitles$, + reload$, // trigger a reload (replacement for deprepcated searchSessionId) })} onApiAvailable={setLensApi} hidePanelChrome={!showPanelChrome}