mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-30 12:25:22 +00:00
fix multiselect trigger onOpen/onClose after first render
This commit is contained in:
parent
2ec1448841
commit
eed4a63243
1 changed files with 18 additions and 13 deletions
|
|
@ -41,7 +41,9 @@ const Multiselect = ({ className, direction, title, options, selected, disabled,
|
||||||
closeMenu();
|
closeMenu();
|
||||||
}
|
}
|
||||||
}, [dataset, onSelect]);
|
}, [dataset, onSelect]);
|
||||||
|
const mountedRef = React.useRef(false);
|
||||||
React.useLayoutEffect(() => {
|
React.useLayoutEffect(() => {
|
||||||
|
if (mountedRef.current) {
|
||||||
if (menuOpen) {
|
if (menuOpen) {
|
||||||
if (typeof onOpen === 'function') {
|
if (typeof onOpen === 'function') {
|
||||||
onOpen({
|
onOpen({
|
||||||
|
|
@ -57,6 +59,9 @@ const Multiselect = ({ className, direction, title, options, selected, disabled,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mountedRef.current = true;
|
||||||
}, [menuOpen]);
|
}, [menuOpen]);
|
||||||
return (
|
return (
|
||||||
<Popup
|
<Popup
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue