Skip to content

Commit

Permalink
fix: drawer panel height
Browse files Browse the repository at this point in the history
  • Loading branch information
goshander committed Nov 22, 2023
1 parent 18b751e commit a0c63d2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
3 changes: 2 additions & 1 deletion src/components/AsideHeader/AsideHeader.scss
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,9 @@ $block: '.#{variables.$ns}aside-header';
left: 0;
right: 0;
bottom: 0;
top: 0;
top: var(--gn-aside-top-panel-height);
overflow: auto;
max-height: calc(100vh - var(--gn-aside-top-panel-height));
}

&__panel {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ body {
&__settings-panel,
&__search-panel {
width: 300px;
height: 100%;
height: calc(100% - 40px);
padding: 20px;
}
}
Expand Down
21 changes: 13 additions & 8 deletions src/components/AsideHeader/useAsideHeaderTopPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,18 @@ export const useAsideHeaderTopPanel = ({
const topRef = React.useRef<HTMLDivElement>(null);
const topHeight = useRefHeight(topRef);

const setAsideTopPanelHeight = React.useCallback((clientHeight: number) => {
document.documentElement.style.setProperty(
'--gn-aside-top-panel-height',
clientHeight + 'px',
);
}, []);

const updateTopSize = React.useCallback(() => {
if (topRef.current) {
const clientHeight = topRef.current?.clientHeight || 0;

document.documentElement.style.setProperty(
'--gn-aside-top-panel-height',
clientHeight + 'px',
);
setAsideTopPanelHeight(topRef.current?.clientHeight || 0);
}
}, [topRef]);
}, [topRef, setAsideTopPanelHeight]);

React.useLayoutEffect(() => {
const updateTopSizeDebounce = debounceFn(updateTopSize, 200, {leading: true});
Expand All @@ -45,7 +47,10 @@ export const useAsideHeaderTopPanel = ({
window.addEventListener('resize', updateTopSizeDebounce);
updateTopSizeDebounce();
}
return () => window.removeEventListener('resize', updateTopSizeDebounce);
return () => {
window.removeEventListener('resize', updateTopSizeDebounce);
setAsideTopPanelHeight(0);
};
}, [topAlert, topHeight, topRef, updateTopSize]);

Check warning on line 54 in src/components/AsideHeader/useAsideHeaderTopPanel.tsx

View workflow job for this annotation

GitHub Actions / Verify Files

React Hook React.useLayoutEffect has a missing dependency: 'setAsideTopPanelHeight'. Either include it or remove the dependency array

return {
Expand Down

0 comments on commit a0c63d2

Please sign in to comment.