diff --git a/src/components/controls/panelSection.tsx b/src/components/controls/panelSection.tsx index bd3c34488..19a4ddf76 100644 --- a/src/components/controls/panelSection.tsx +++ b/src/components/controls/panelSection.tsx @@ -31,6 +31,16 @@ export const PanelSection = ({ panel, title, tooltip, options=undefined }: Props setOptionsAreVisible(panelIsVisible) }, [panelIsVisible]) + const [contentHeight, setContentHeight] = React.useState(1000); + const optionsContainer = React.useRef(null); + + // FIXME: useLayoutEffect? + React.useEffect(() => { + if (optionsContainer.current) { + setContentHeight(optionsContainer.current.scrollHeight); // FIXME: offsetHeight? + } + }, [options]); + return ( - + {options} diff --git a/src/components/controls/styles.js b/src/components/controls/styles.js index 702905b9a..fb5c33e29 100644 --- a/src/components/controls/styles.js +++ b/src/components/controls/styles.js @@ -56,7 +56,7 @@ export const PanelOptionsContainer = styled.div` &.open { visibility: visible; - max-height: 100vh; + max-height: ${({ contentHeight }) => `${contentHeight}px`}; } `