[Lens] Fix missing embeddable panel titles (#203355)

## Summary

When using the new Custom Lens embeddable component, the titles are
hidden by default due to to a regression introduced in
https://github.com/elastic/kibana/pull/186642.
This PR should fix the correct title handling of the header visibility
by hiding or showing the wrapping Panel title depending on the
`hidePanelTitles` props of the `LensRenderer` component


fix https://github.com/elastic/kibana/issues/203354
This commit is contained in:
Marco Vettorello 2024-12-10 16:39:15 +01:00 committed by GitHub
parent 101e797e9d
commit 6e57a23d18
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -59,6 +59,7 @@ export function LensRenderer({
filters,
timeRange,
disabledActions,
hidePanelTitles,
...props
}: LensRendererProps) {
// Use the settings interface to store panel settings
@ -71,6 +72,7 @@ export function LensRenderer({
}, []);
const disabledActionIds$ = useObservableVariable(disabledActions);
const viewMode$ = useObservableVariable(viewMode);
const hidePanelTitles$ = useObservableVariable(hidePanelTitles);
// Lens API will be set once, but when set trigger a reflow to adopt the latest attributes
const [lensApi, setLensApi] = useState<LensApi | undefined>(undefined);
@ -112,7 +114,6 @@ export function LensRenderer({
const panelProps: PanelProps = useMemo(() => {
return {
hideInspector: !showInspector,
hideHeader: showPanelChrome,
showNotifications: false,
showShadow: false,
showBadges: false,
@ -124,7 +125,7 @@ export function LensRenderer({
return (extraActions ?? []).concat(actions || []);
},
};
}, [showInspector, showPanelChrome, withDefaultActions, extraActions, lensApi]);
}, [showInspector, withDefaultActions, extraActions, lensApi]);
return (
<ReactEmbeddableRenderer<LensSerializedState, LensRuntimeState, LensApi>
@ -147,6 +148,7 @@ export function LensRenderer({
...initialStateRef.current,
attributes: props.attributes,
}),
hidePanelTitle: hidePanelTitles$,
})}
onApiAvailable={setLensApi}
hidePanelChrome={!showPanelChrome}