Update SelectBox.js

This commit is contained in:
James Hawkins 2021-10-26 13:25:34 +01:00 committed by GitHub
parent 863a9823f1
commit e1eea3de89
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -40,13 +40,11 @@ export function SelectBox({ options, selectedItem, setSelectedItem }) {
useEffect(() => { useEffect(() => {
// add when mounted // add when mounted
document.addEventListener("mousedown", handleClick); document.addEventListener("mousedown", handleClick);
//document.addEventListener("scroll", closeDropdown);
// return function to be called when unmounted // return function to be called when unmounted
return () => { return () => {
document.removeEventListener("mousedown", handleClick); document.removeEventListener("mousedown", handleClick);
document.removeEventListener("scroll", closeDropdown)
}; };
}, []); }, [handleClick]);
const onOptionClick = (e, option, i) => { const onOptionClick = (e, option, i) => {
e.stopPropagation() e.stopPropagation()
@ -68,4 +66,4 @@ export function SelectBox({ options, selectedItem, setSelectedItem }) {
</div> </div>
</div> </div>
) )
} }