Skip to content

Commit d6cb83a

Browse files
committed
Clean up top nav bar code
1 parent 632e057 commit d6cb83a

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

src/plugins/dashboard/public/dashboard_app/top_nav/dashboard_top_nav.tsx

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,19 @@ export function DashboardTopNav({
123123
if (!embedSettings) setChromeVisibility(viewMode !== ViewMode.PRINT);
124124
}, [embedSettings, setChromeVisibility, viewMode]);
125125

126+
/**
127+
* Keep track of the height of the top nav bar as it changes so that the padding at the top of the
128+
* dashboard viewport can be adjusted dynamically as it changes
129+
*/
130+
const resizeRef = useRef<HTMLDivElement>(null);
131+
const dimensions = useResizeObserver(resizeRef.current);
132+
useEffect(() => {
133+
if (dimensions.height !== currentHeight) {
134+
onHeightChange(dimensions.height);
135+
setCurrentHeight(dimensions.height);
136+
}
137+
}, [dimensions, currentHeight, onHeightChange]);
138+
126139
/**
127140
* populate recently accessed, and set is chrome visible.
128141
*/
@@ -220,16 +233,6 @@ export function DashboardTopNav({
220233
dashboardContainer.clearOverlays();
221234
});
222235

223-
const resizeRef = useRef<HTMLDivElement>(null);
224-
const dimensions = useResizeObserver(resizeRef.current);
225-
226-
useEffect(() => {
227-
if (dimensions.height !== currentHeight) {
228-
onHeightChange(dimensions.height);
229-
setCurrentHeight(dimensions.height);
230-
}
231-
}, [dimensions, currentHeight, onHeightChange]);
232-
233236
return (
234237
<div ref={resizeRef} className={'dashboardTopNav'}>
235238
<h1

0 commit comments

Comments
 (0)