diff --git a/.changeset/dirty-planes-breathe.md b/.changeset/dirty-planes-breathe.md new file mode 100644 index 0000000000..d97a68e888 --- /dev/null +++ b/.changeset/dirty-planes-breathe.md @@ -0,0 +1,5 @@ +--- +"@ultraviolet/ui": patch +--- + +Fix `` resize issue in a modal diff --git a/packages/ui/src/components/SelectInputV2/Dropdown.tsx b/packages/ui/src/components/SelectInputV2/Dropdown.tsx index 2e663726ba..27ca259847 100644 --- a/packages/ui/src/components/SelectInputV2/Dropdown.tsx +++ b/packages/ui/src/components/SelectInputV2/Dropdown.tsx @@ -678,10 +678,13 @@ export const Dropdown = ({ const [defaultSearchValue, setDefaultSearch] = useState(null) const ref = useRef(null) const [search, setSearch] = useState('') - const [maxWidth, setWidth] = useState(refSelect.current?.offsetWidth) + const [maxWidth, setWidth] = useState() const resizeDropdown = useCallback(() => { - if (refSelect.current) { + if ( + refSelect.current && + refSelect.current.getBoundingClientRect().width > 0 + ) { setWidth(refSelect.current.getBoundingClientRect().width) } }, [refSelect]) @@ -808,7 +811,7 @@ export const Dropdown = ({ } placement="bottom" disableAnimation - maxWidth={maxWidth} + maxWidth={maxWidth ?? refSelect.current?.offsetWidth} hasArrow={false} ref={ref} tabIndex={0}