mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
- Stop the default behavior on the custom menu button. (#4440)
- Refactor menu click handler function
This commit is contained in:
parent
198a2a63f2
commit
18ba4009e0
@ -68,6 +68,13 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
|
|||||||
if (closeOnSelect) closeDropdown();
|
if (closeOnSelect) closeDropdown();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleMenuButtonClick = (e:React.MouseEvent<HTMLButtonElement, MouseEvent>)=>{
|
||||||
|
e.stopPropagation();
|
||||||
|
e.preventDefault()
|
||||||
|
isOpen ? closeDropdown() : openDropdown();
|
||||||
|
if (menuButtonOnClick) menuButtonOnClick();
|
||||||
|
}
|
||||||
|
|
||||||
useOutsideClickDetector(dropdownRef, closeDropdown);
|
useOutsideClickDetector(dropdownRef, closeDropdown);
|
||||||
|
|
||||||
let menuItems = (
|
let menuItems = (
|
||||||
@ -112,11 +119,7 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
|
|||||||
<button
|
<button
|
||||||
ref={setReferenceElement}
|
ref={setReferenceElement}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={(e) => {
|
onClick={handleMenuButtonClick}
|
||||||
e.stopPropagation();
|
|
||||||
isOpen ? closeDropdown() : openDropdown();
|
|
||||||
if (menuButtonOnClick) menuButtonOnClick();
|
|
||||||
}}
|
|
||||||
className={customButtonClassName}
|
className={customButtonClassName}
|
||||||
tabIndex={customButtonTabIndex}
|
tabIndex={customButtonTabIndex}
|
||||||
>
|
>
|
||||||
@ -130,12 +133,7 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
|
|||||||
<button
|
<button
|
||||||
ref={setReferenceElement}
|
ref={setReferenceElement}
|
||||||
type="button"
|
type="button"
|
||||||
onClick={(e) => {
|
onClick={handleMenuButtonClick}
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
isOpen ? closeDropdown() : openDropdown();
|
|
||||||
if (menuButtonOnClick) menuButtonOnClick();
|
|
||||||
}}
|
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
className={`relative grid place-items-center rounded p-1 text-custom-text-200 outline-none hover:text-custom-text-100 ${
|
className={`relative grid place-items-center rounded p-1 text-custom-text-200 outline-none hover:text-custom-text-100 ${
|
||||||
disabled ? "cursor-not-allowed" : "cursor-pointer hover:bg-custom-background-80"
|
disabled ? "cursor-not-allowed" : "cursor-pointer hover:bg-custom-background-80"
|
||||||
@ -157,12 +155,7 @@ const CustomMenu = (props: ICustomMenuDropdownProps) => {
|
|||||||
? "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={(e) => {
|
onClick={handleMenuButtonClick}
|
||||||
e.preventDefault();
|
|
||||||
e.stopPropagation();
|
|
||||||
isOpen ? closeDropdown() : openDropdown();
|
|
||||||
if (menuButtonOnClick) menuButtonOnClick();
|
|
||||||
}}
|
|
||||||
tabIndex={customButtonTabIndex}
|
tabIndex={customButtonTabIndex}
|
||||||
>
|
>
|
||||||
{label}
|
{label}
|
||||||
|
Loading…
Reference in New Issue
Block a user