diff --git a/ui/src/Components/Grid/AlertGrid/index.tsx b/ui/src/Components/Grid/AlertGrid/index.tsx index 169dabe08..a5dea6794 100644 --- a/ui/src/Components/Grid/AlertGrid/index.tsx +++ b/ui/src/Components/Grid/AlertGrid/index.tsx @@ -1,4 +1,4 @@ -import React, { FC, Ref, useEffect, useState } from "react"; +import React, { FC, useEffect, useState, useRef } from "react"; import { autorun } from "mobx"; import { observer } from "mobx-react-lite"; @@ -21,8 +21,9 @@ const AlertGrid: FC<{ silenceFormStore: SilenceFormStore; settingsStore: Settings; }> = ({ alertStore, settingsStore, silenceFormStore }) => { + const ref = useRef(); const { width: windowWidth } = useWindowSize(); - const { ref, width: bodyWidth } = useDimensions(); + const { observe, width: bodyWidth } = useDimensions(); const [gridSizesConfig, setGridSizesConfig] = useState( GridSizesConfig(settingsStore.gridConfig.config.groupWidth) @@ -58,7 +59,12 @@ const AlertGrid: FC<{ return ( -
} /> +
{ + observe(el as HTMLElement); + ref.current = el as HTMLDivElement; + }} + /> {alertStore.data.grids.map((grid) => ( (); + const { observe, height } = useDimensions({}); const updateBodyPaddingTop = useCallback( (idle) => { @@ -102,7 +103,10 @@ const NavBar: FC<{ exit >