From e14bb282ee76aa65c413b8d1718d0a333cbf3f41 Mon Sep 17 00:00:00 2001 From: Constance Chen Date: Mon, 29 Aug 2022 15:16:38 -0700 Subject: [PATCH] Fix inline styles not correctly updating if `sticky` prop is not set --- src/components/page/page_sidebar/page_sidebar.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/components/page/page_sidebar/page_sidebar.tsx b/src/components/page/page_sidebar/page_sidebar.tsx index bd39401dbf58..80ecc9c7f989 100644 --- a/src/components/page/page_sidebar/page_sidebar.tsx +++ b/src/components/page/page_sidebar/page_sidebar.tsx @@ -81,6 +81,11 @@ export const EuiPageSidebar: FunctionComponent = ({ }); useEffect(() => { + let updatedStyles = { + ...style, + ...logicalStyle('min-width', isResponding ? '100%' : minWidth), + }; + if (sticky) { const euiHeaderFixedCounter = Number( document.body.dataset.fixedHeaders ?? 0 @@ -91,13 +96,14 @@ export const EuiPageSidebar: FunctionComponent = ({ ? 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 (