diff --git a/src/Dropdown.tsx b/src/Dropdown.tsx index b22f9f9..b9542fd 100644 --- a/src/Dropdown.tsx +++ b/src/Dropdown.tsx @@ -66,10 +66,18 @@ function Dropdown(props: DropdownProps, ref) { return overlayElement; }; + const onVisibleChange = (visible: boolean) => { + const { onVisibleChange } = props; + setTriggerVisible(visible); + if (typeof onVisibleChange === 'function') { + onVisibleChange(visible); + } + }; + const onClick = e => { const { onOverlayClick } = props; const overlayProps = getOverlayElement().props; - setTriggerVisible(false); + onVisibleChange(false); if (onOverlayClick) { onOverlayClick(e); @@ -79,14 +87,6 @@ function Dropdown(props: DropdownProps, ref) { } }; - const onVisibleChange = (visible: boolean) => { - const { onVisibleChange } = props; - setTriggerVisible(visible); - if (typeof onVisibleChange === 'function') { - onVisibleChange(visible); - } - }; - const getMenuElement = () => { const overlayElement = getOverlayElement(); const extraOverlayProps = {