Fixed: Closing on click outside select input and styling on Library Import

pull/7387/head
Mark McDowall 4 months ago committed by Mark McDowall
parent 936cf699ff
commit 3e99917e9d

@ -1,18 +1,10 @@
.inputContainer { .inputContainer {
margin-right: 20px; margin-right: 20px;
min-width: 150px; min-width: 150px;
div {
margin-top: 10px;
&:first-child {
margin-top: 0;
}
}
} }
.label { .label {
margin-bottom: 3px; margin-bottom: 10px;
font-weight: bold; font-weight: bold;
} }

@ -192,7 +192,7 @@ function EnhancedSelectInput<T extends EnhancedSelectInputValue<V>, V>(
const { top, bottom } = data.offsets.reference; const { top, bottom } = data.offsets.reference;
const windowHeight = window.innerHeight; const windowHeight = window.innerHeight;
if (/^botton/.test(data.placement)) { if (/^bottom/.test(data.placement)) {
data.styles.maxHeight = windowHeight - bottom; data.styles.maxHeight = windowHeight - bottom;
} else { } else {
data.styles.maxHeight = top; data.styles.maxHeight = top;
@ -233,18 +233,12 @@ function EnhancedSelectInput<T extends EnhancedSelectInputValue<V>, V>(
}, [handleWindowClick]); }, [handleWindowClick]);
const handlePress = useCallback(() => { const handlePress = useCallback(() => {
if (isOpen) {
removeListener();
} else {
addListener();
}
if (!isOpen && onOpen) { if (!isOpen && onOpen) {
onOpen(); onOpen();
} }
setIsOpen(!isOpen); setIsOpen(!isOpen);
}, [isOpen, setIsOpen, addListener, removeListener, onOpen]); }, [isOpen, setIsOpen, onOpen]);
const handleSelect = useCallback( const handleSelect = useCallback(
(newValue: ArrayElement<V>) => { (newValue: ArrayElement<V>) => {
@ -411,6 +405,16 @@ function EnhancedSelectInput<T extends EnhancedSelectInputValue<V>, V>(
} }
}); });
useEffect(() => {
if (isOpen) {
addListener();
} else {
removeListener();
}
return removeListener;
}, [isOpen, addListener, removeListener]);
return ( return (
<div> <div>
<Manager> <Manager>

Loading…
Cancel
Save