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