mirror of
https://github.com/lingble/twenty.git
synced 2025-10-29 20:02:29 +00:00
fix: Country Dropdown not closing with AddressInput (#8147)
## Description - This PR fixes #8080 - The Country Selector dropdown closes with Address Input `clickOutside` function ## Changes https://github.com/user-attachments/assets/1ab85175-9ce9-40d2-ac52-14bfe87e254f --------- Co-authored-by: Devessier <baptiste@devessier.fr>
This commit is contained in:
@@ -70,6 +70,7 @@ export const Dropdown = ({
|
||||
closeDropdown,
|
||||
dropdownWidth,
|
||||
setDropdownPlacement,
|
||||
resetDropdown,
|
||||
} = useDropdown(dropdownId);
|
||||
|
||||
const offsetMiddlewares = [];
|
||||
@@ -130,6 +131,12 @@ export const Dropdown = ({
|
||||
[closeDropdown],
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
resetDropdown();
|
||||
};
|
||||
}, [resetDropdown]);
|
||||
|
||||
return (
|
||||
<DropdownScope dropdownScopeId={getScopeIdFromComponentId(dropdownId)}>
|
||||
<div ref={containerRef} className={className}>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useRecoilState } from 'recoil';
|
||||
import { useRecoilCallback, useRecoilState } from 'recoil';
|
||||
|
||||
import { useDropdownStates } from '@/ui/layout/dropdown/hooks/internal/useDropdownStates';
|
||||
import { usePreviousHotkeyScope } from '@/ui/utilities/hotkey/hooks/usePreviousHotkeyScope';
|
||||
@@ -56,6 +56,16 @@ export const useDropdown = (dropdownId?: string) => {
|
||||
}
|
||||
};
|
||||
|
||||
const resetDropdown = useRecoilCallback(
|
||||
({ reset }) =>
|
||||
() => {
|
||||
reset(dropdownHotkeyScopeState);
|
||||
reset(dropdownWidthState);
|
||||
reset(isDropdownOpenState);
|
||||
},
|
||||
[dropdownHotkeyScopeState, dropdownWidthState, isDropdownOpenState],
|
||||
);
|
||||
|
||||
return {
|
||||
scopeId,
|
||||
isDropdownOpen,
|
||||
@@ -66,5 +76,6 @@ export const useDropdown = (dropdownId?: string) => {
|
||||
setDropdownWidth,
|
||||
dropdownPlacement,
|
||||
setDropdownPlacement,
|
||||
resetDropdown,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user