Skip to content

Commit

Permalink
Fix content going off page sometimes
Browse files Browse the repository at this point in the history
- Calculated app bar height from useAppBarHeight could be incorrect
  after exiting theater mode.
- Subscribed to additional event to recalculate the app bar height
  state.
  • Loading branch information
killergerbah committed Apr 17, 2024
1 parent 02acd9f commit 2a95881
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion common/app/hooks/use-app-bar-height.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,19 @@ export const useAppBarHeight = () => {
setAppbarHeight(appBar?.clientHeight || 0);
}

const observer = new MutationObserver(() => {
setAppbarHeight(appBar?.clientHeight || 0);
});

if (appBar) {
observer.observe(appBar, { attributes: true, attributeFilter: ['class'] });
}

window.addEventListener('resize', handleResize);
return () => window.removeEventListener('resize', handleResize);
return () => {
window.removeEventListener('resize', handleResize);
observer.disconnect();
};
}, []);

return appbarHeight;
Expand Down

0 comments on commit 2a95881

Please sign in to comment.