mirror of
https://github.com/elastic/kibana.git
synced 2025-06-27 18:51:07 -04:00
[AO] use toMountPoint from react-kibana-mount for header menu portal (#167126)
Fixes https://github.com/elastic/kibana/issues/164366
### Acceptance Criteria
- use `toMountPoint` from `@kbn/react-kibana-mount` for
[kibana/x-pack/plugins/observability/public/pages/overview/components/header_menu/header_menu_portal.tsx](fcf838e1f3/x-pack/plugins/observability/public/pages/overview/components/header_menu/header_menu_portal.tsx (L10)
)
---------
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
8e6101e752
commit
ba31c76f31
2 changed files with 8 additions and 4 deletions
|
@ -7,9 +7,9 @@
|
|||
|
||||
import React, { ReactNode, useEffect, useMemo } from 'react';
|
||||
import { createHtmlPortalNode, InPortal, OutPortal } from 'react-reverse-portal';
|
||||
import { toMountPoint } from '@kbn/kibana-react-plugin/public';
|
||||
import { toMountPoint } from '@kbn/react-kibana-mount';
|
||||
import { AppMountParameters } from '@kbn/core/public';
|
||||
|
||||
import { useKibana } from '../../../../utils/kibana_react';
|
||||
export interface HeaderMenuPortalProps {
|
||||
children: ReactNode;
|
||||
setHeaderActionMenu: AppMountParameters['setHeaderActionMenu'];
|
||||
|
@ -22,11 +22,14 @@ export default function HeaderMenuPortal({
|
|||
setHeaderActionMenu,
|
||||
theme$,
|
||||
}: HeaderMenuPortalProps) {
|
||||
const { i18n } = useKibana().services;
|
||||
const portalNode = useMemo(() => createHtmlPortalNode(), []);
|
||||
|
||||
useEffect(() => {
|
||||
setHeaderActionMenu((element) => {
|
||||
const mount = toMountPoint(<OutPortal node={portalNode} />, { theme$ });
|
||||
const mount = toMountPoint(<OutPortal node={portalNode} />, {
|
||||
...{ theme: { theme$ }, i18n },
|
||||
});
|
||||
return mount(element);
|
||||
});
|
||||
|
||||
|
@ -34,7 +37,7 @@ export default function HeaderMenuPortal({
|
|||
portalNode.unmount();
|
||||
setHeaderActionMenu(undefined);
|
||||
};
|
||||
}, [portalNode, setHeaderActionMenu, theme$]);
|
||||
}, [portalNode, setHeaderActionMenu, i18n, theme$]);
|
||||
|
||||
return <InPortal node={portalNode}>{children}</InPortal>;
|
||||
}
|
||||
|
|
|
@ -87,6 +87,7 @@
|
|||
"@kbn/aiops-plugin",
|
||||
"@kbn/content-management-plugin",
|
||||
"@kbn/deeplinks-observability",
|
||||
"@kbn/react-kibana-mount",
|
||||
"@kbn/react-kibana-context-theme"
|
||||
],
|
||||
"exclude": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue