mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Navigation: Fix <Portal>
when bodyScrolling
is enabled (#91335)
fix portal when bodyScrolling is enabled
This commit is contained in:
parent
25b65d96c7
commit
ce8f5b5e1a
@ -1,8 +1,11 @@
|
||||
import { css, cx } from '@emotion/css';
|
||||
import { PropsWithChildren, useLayoutEffect, useRef } from 'react';
|
||||
import * as React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
import { useTheme2 } from '../../themes';
|
||||
import { GrafanaTheme2 } from '@grafana/data';
|
||||
|
||||
import { useStyles2, useTheme2 } from '../../themes';
|
||||
|
||||
interface Props {
|
||||
className?: string;
|
||||
@ -47,9 +50,27 @@ export function getPortalContainer() {
|
||||
|
||||
/** @internal */
|
||||
export function PortalContainer() {
|
||||
return <div id="grafana-portal-container" />;
|
||||
const styles = useStyles2(getStyles);
|
||||
const isBodyScrolling = window.grafanaBootData?.settings.featureToggles.bodyScrolling;
|
||||
return (
|
||||
<div
|
||||
id="grafana-portal-container"
|
||||
className={cx({
|
||||
[styles.grafanaPortalContainer]: isBodyScrolling,
|
||||
})}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const getStyles = (theme: GrafanaTheme2) => ({
|
||||
grafanaPortalContainer: css({
|
||||
position: 'fixed',
|
||||
top: 0,
|
||||
width: '100%',
|
||||
zIndex: theme.zIndex.portal,
|
||||
}),
|
||||
});
|
||||
|
||||
export const RefForwardingPortal = React.forwardRef<HTMLDivElement, Props>((props, ref) => {
|
||||
return <Portal {...props} forwardedRef={ref} />;
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user