Fix close command menu button (#12282)
Fixes #12280 The `dataClickOutsideId` and `dataGloballyPreventClickOutside` props weren't passed to the button components. This PR fixes this and introduces the type `ClickOutsideAttributes`. https://github.com/user-attachments/assets/38b1a6f9-8f3a-43d2-aa7b-aaa259ac6737
This commit is contained in:
@ -125,9 +125,7 @@ export const PageHeaderToggleCommandMenuButton = () => {
|
|||||||
animatedSvg={
|
animatedSvg={
|
||||||
<AnimatedIcon isCommandMenuOpened={isCommandMenuOpened} />
|
<AnimatedIcon isCommandMenuOpened={isCommandMenuOpened} />
|
||||||
}
|
}
|
||||||
data-click-outside-id={
|
dataClickOutsideId={PAGE_HEADER_COMMAND_MENU_BUTTON_CLICK_OUTSIDE_ID}
|
||||||
PAGE_HEADER_COMMAND_MENU_BUTTON_CLICK_OUTSIDE_ID
|
|
||||||
}
|
|
||||||
dataTestId="page-header-command-menu-button"
|
dataTestId="page-header-command-menu-button"
|
||||||
size={isMobile ? 'medium' : 'small'}
|
size={isMobile ? 'medium' : 'small'}
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
|
|||||||
@ -31,6 +31,8 @@ const StyledButton = styled.button<
|
|||||||
| 'justify'
|
| 'justify'
|
||||||
| 'to'
|
| 'to'
|
||||||
| 'target'
|
| 'target'
|
||||||
|
| 'dataClickOutsideId'
|
||||||
|
| 'dataGloballyPreventClickOutside'
|
||||||
>
|
>
|
||||||
>`
|
>`
|
||||||
align-items: center;
|
align-items: center;
|
||||||
@ -404,6 +406,8 @@ export const AnimatedButton = ({
|
|||||||
ariaLabel,
|
ariaLabel,
|
||||||
animate,
|
animate,
|
||||||
transition,
|
transition,
|
||||||
|
dataClickOutsideId,
|
||||||
|
dataGloballyPreventClickOutside,
|
||||||
}: AnimatedButtonProps) => {
|
}: AnimatedButtonProps) => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const isMobile = useIsMobile();
|
const isMobile = useIsMobile();
|
||||||
@ -428,6 +432,8 @@ export const AnimatedButton = ({
|
|||||||
target={target}
|
target={target}
|
||||||
data-testid={dataTestId}
|
data-testid={dataTestId}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
|
data-click-outside-id={dataClickOutsideId}
|
||||||
|
data-globally-prevent-click-outside={dataGloballyPreventClickOutside}
|
||||||
>
|
>
|
||||||
{Icon && (
|
{Icon && (
|
||||||
<StyledIconContainer animate={animate} transition={transition}>
|
<StyledIconContainer animate={animate} transition={transition}>
|
||||||
|
|||||||
@ -6,6 +6,7 @@ import { ButtonHotkeys } from '@ui/input/button/components/Button/internal/Butto
|
|||||||
import { ButtonIcon } from '@ui/input/button/components/Button/internal/ButtonIcon';
|
import { ButtonIcon } from '@ui/input/button/components/Button/internal/ButtonIcon';
|
||||||
import { ButtonSoon } from '@ui/input/button/components/Button/internal/ButtonSoon';
|
import { ButtonSoon } from '@ui/input/button/components/Button/internal/ButtonSoon';
|
||||||
import { useIsMobile } from '@ui/utilities';
|
import { useIsMobile } from '@ui/utilities';
|
||||||
|
import { ClickOutsideAttributes } from '@ui/utilities/types/ClickOutsideAttributes';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { isDefined } from 'twenty-shared/utils';
|
import { isDefined } from 'twenty-shared/utils';
|
||||||
@ -37,7 +38,8 @@ export type ButtonProps = {
|
|||||||
hotkeys?: string[];
|
hotkeys?: string[];
|
||||||
ariaLabel?: string;
|
ariaLabel?: string;
|
||||||
isLoading?: boolean;
|
isLoading?: boolean;
|
||||||
} & React.ComponentProps<'button'>;
|
} & Pick<React.ComponentProps<'button'>, 'type'> &
|
||||||
|
ClickOutsideAttributes;
|
||||||
|
|
||||||
const StyledButton = styled('button', {
|
const StyledButton = styled('button', {
|
||||||
shouldForwardProp: (prop) =>
|
shouldForwardProp: (prop) =>
|
||||||
@ -434,6 +436,8 @@ export const Button = ({
|
|||||||
to,
|
to,
|
||||||
target,
|
target,
|
||||||
dataTestId,
|
dataTestId,
|
||||||
|
dataClickOutsideId,
|
||||||
|
dataGloballyPreventClickOutside,
|
||||||
hotkeys,
|
hotkeys,
|
||||||
ariaLabel,
|
ariaLabel,
|
||||||
type,
|
type,
|
||||||
@ -467,6 +471,8 @@ export const Button = ({
|
|||||||
as={to ? Link : 'button'}
|
as={to ? Link : 'button'}
|
||||||
target={target}
|
target={target}
|
||||||
data-testid={dataTestId}
|
data-testid={dataTestId}
|
||||||
|
data-click-outside-id={dataClickOutsideId}
|
||||||
|
data-globally-prevent-click-outside={dataGloballyPreventClickOutside}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
type={type}
|
type={type}
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
|
|||||||
@ -0,0 +1,4 @@
|
|||||||
|
export type ClickOutsideAttributes = {
|
||||||
|
dataClickOutsideId?: string;
|
||||||
|
dataGloballyPreventClickOutside?: boolean;
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user