Skip to content

Commit

Permalink
Fix inline styles not correctly updating if sticky prop is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen committed Aug 29, 2022
1 parent c00bc60 commit e14bb28
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/components/page/page_sidebar/page_sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ export const EuiPageSidebar: FunctionComponent<EuiPageSidebarProps> = ({
});

useEffect(() => {
let updatedStyles = {
...style,
...logicalStyle('min-width', isResponding ? '100%' : minWidth),
};

if (sticky) {
const euiHeaderFixedCounter = Number(
document.body.dataset.fixedHeaders ?? 0
Expand All @@ -91,13 +96,14 @@ export const EuiPageSidebar: FunctionComponent<EuiPageSidebarProps> = ({
? sticky?.offset
: themeContext.euiTheme.base * 3 * euiHeaderFixedCounter;

setInlineStyles({
...style,
...logicalStyle('min-width', isResponding ? '100%' : minWidth),
updatedStyles = {
...updatedStyles,
...logicalStyle('top', offset),
...logicalStyle('max-height', `calc(100vh - ${offset}px)`),
});
};
}

setInlineStyles(updatedStyles);
}, [style, sticky, themeContext.euiTheme.base, isResponding, minWidth]);

return (
Expand Down

0 comments on commit e14bb28

Please sign in to comment.