forked from github/plane
[WEB-1098] chore: dropdowns enhancement (#4375)
This commit is contained in:
parent
fb68b77068
commit
a85517de99
@ -66,6 +66,11 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
|
|||||||
const handleKeyDown = useDropdownKeyDown(openDropdown, closeDropdown, isOpen);
|
const handleKeyDown = useDropdownKeyDown(openDropdown, closeDropdown, isOpen);
|
||||||
useOutsideClickDetector(dropdownRef, closeDropdown);
|
useOutsideClickDetector(dropdownRef, closeDropdown);
|
||||||
|
|
||||||
|
const toggleDropdown = () => {
|
||||||
|
if (isOpen) closeDropdown();
|
||||||
|
else openDropdown();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Combobox
|
<Combobox
|
||||||
as="div"
|
as="div"
|
||||||
@ -90,7 +95,7 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
|
|||||||
? "cursor-not-allowed text-custom-text-200"
|
? "cursor-not-allowed text-custom-text-200"
|
||||||
: "cursor-pointer hover:bg-custom-background-80"
|
: "cursor-pointer hover:bg-custom-background-80"
|
||||||
} ${customButtonClassName}`}
|
} ${customButtonClassName}`}
|
||||||
onClick={openDropdown}
|
onClick={toggleDropdown}
|
||||||
>
|
>
|
||||||
{customButton}
|
{customButton}
|
||||||
</button>
|
</button>
|
||||||
@ -107,7 +112,7 @@ export const CustomSearchSelect = (props: ICustomSearchSelectProps) => {
|
|||||||
? "cursor-not-allowed text-custom-text-200"
|
? "cursor-not-allowed text-custom-text-200"
|
||||||
: "cursor-pointer hover:bg-custom-background-80"
|
: "cursor-pointer hover:bg-custom-background-80"
|
||||||
} ${buttonClassName}`}
|
} ${buttonClassName}`}
|
||||||
onClick={openDropdown}
|
onClick={toggleDropdown}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
{!noChevron && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
|
{!noChevron && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
|
||||||
|
@ -47,6 +47,11 @@ const CustomSelect = (props: ICustomSelectProps) => {
|
|||||||
const handleKeyDown = useDropdownKeyDown(openDropdown, closeDropdown, isOpen);
|
const handleKeyDown = useDropdownKeyDown(openDropdown, closeDropdown, isOpen);
|
||||||
useOutsideClickDetector(dropdownRef, closeDropdown);
|
useOutsideClickDetector(dropdownRef, closeDropdown);
|
||||||
|
|
||||||
|
const toggleDropdown = () => {
|
||||||
|
if (isOpen) closeDropdown();
|
||||||
|
else openDropdown();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Listbox
|
<Listbox
|
||||||
as="div"
|
as="div"
|
||||||
@ -67,7 +72,7 @@ const CustomSelect = (props: ICustomSelectProps) => {
|
|||||||
className={`flex items-center justify-between gap-1 text-xs ${
|
className={`flex items-center justify-between gap-1 text-xs ${
|
||||||
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
|
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
|
||||||
} ${customButtonClassName}`}
|
} ${customButtonClassName}`}
|
||||||
onClick={openDropdown}
|
onClick={toggleDropdown}
|
||||||
>
|
>
|
||||||
{customButton}
|
{customButton}
|
||||||
</button>
|
</button>
|
||||||
@ -82,7 +87,7 @@ const CustomSelect = (props: ICustomSelectProps) => {
|
|||||||
} ${
|
} ${
|
||||||
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
|
disabled ? "cursor-not-allowed text-custom-text-200" : "cursor-pointer hover:bg-custom-background-80"
|
||||||
} ${buttonClassName}`}
|
} ${buttonClassName}`}
|
||||||
onClick={openDropdown}
|
onClick={toggleDropdown}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
{!noChevron && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
|
{!noChevron && !disabled && <ChevronDown className="h-3 w-3" aria-hidden="true" />}
|
||||||
|
Loading…
Reference in New Issue
Block a user