10004 tasks will not delete in people view (#10039)

Fixes #10004 
- Fixed `useListenClickOutside` which wasn't working with
`excludeClassNames` for `comparePixels` mode
- Added `emitCloseEvent` parameter to the `closeRightDrawer` function
because closing the right drawer after deleting a note or a task was
triggering an update after the deletion.

This bug was only for the old version of the command menu.
This commit is contained in:
Raphaël Bosi
2025-02-05 18:25:39 +01:00
committed by GitHub
parent e3182a145d
commit 5528577707
6 changed files with 27 additions and 20 deletions

View File

@ -85,7 +85,7 @@ export const useDeleteSingleRecordAction: ActionHookWithObjectMetadataItem = ({
onConfirmClick={() => { onConfirmClick={() => {
handleDeleteClick(); handleDeleteClick();
if (isInRightDrawer) { if (isInRightDrawer) {
closeRightDrawer(); closeRightDrawer({ emitCloseEvent: false });
} }
}} }}
deleteButtonText={'Delete Record'} deleteButtonText={'Delete Record'}

View File

@ -120,6 +120,7 @@ export const ConfirmationModal = ({
isClosable={true} isClosable={true}
padding="large" padding="large"
modalVariant={modalVariant} modalVariant={modalVariant}
className="confirmation-modal"
> >
<StyledCenteredTitle> <StyledCenteredTitle>
<H1Title title={title} fontColor={H1TitleFontColor.Primary} /> <H1Title title={title} fontColor={H1TitleFontColor.Primary} />

View File

@ -42,6 +42,7 @@ export const RightDrawerContainer = ({
rightDrawerRef, rightDrawerRef,
...(workflowReactFlowRef ? [workflowReactFlowRef] : []), ...(workflowReactFlowRef ? [workflowReactFlowRef] : []),
], ],
excludeClassNames: ['confirmation-modal'],
listenerId: RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID, listenerId: RIGHT_DRAWER_CLICK_OUTSIDE_LISTENER_ID,
callback: useRecoilCallback( callback: useRecoilCallback(
({ snapshot, set }) => ({ snapshot, set }) =>

View File

@ -10,7 +10,7 @@ export const RightDrawerTopBarExpandButton = ({ to }: { to: string }) => {
size="medium" size="medium"
accent="tertiary" accent="tertiary"
Icon={IconExternalLink} Icon={IconExternalLink}
onClick={closeRightDrawer} onClick={() => closeRightDrawer()}
/> />
</UndecoratedLink> </UndecoratedLink>
); );

View File

@ -7,6 +7,7 @@ import { useCommandMenu } from '@/command-menu/hooks/useCommandMenu';
import { emitRightDrawerCloseEvent } from '@/ui/layout/right-drawer/utils/emitRightDrawerCloseEvent'; import { emitRightDrawerCloseEvent } from '@/ui/layout/right-drawer/utils/emitRightDrawerCloseEvent';
import { mapRightDrawerPageToCommandMenuPage } from '@/ui/layout/right-drawer/utils/mapRightDrawerPageToCommandMenuPage'; import { mapRightDrawerPageToCommandMenuPage } from '@/ui/layout/right-drawer/utils/mapRightDrawerPageToCommandMenuPage';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled'; import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';
import { isDefined } from 'twenty-shared';
import { IconComponent } from 'twenty-ui'; import { IconComponent } from 'twenty-ui';
import { FeatureFlagKey } from '~/generated/graphql'; import { FeatureFlagKey } from '~/generated/graphql';
import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState'; import { isRightDrawerOpenState } from '../states/isRightDrawerOpenState';
@ -56,10 +57,12 @@ export const useRightDrawer = () => {
const closeRightDrawer = useRecoilCallback( const closeRightDrawer = useRecoilCallback(
({ set }) => ({ set }) =>
() => { (args?: { emitCloseEvent?: boolean }) => {
set(isRightDrawerOpenState, false); set(isRightDrawerOpenState, false);
set(isRightDrawerMinimizedState, false); set(isRightDrawerMinimizedState, false);
emitRightDrawerCloseEvent(); if (isDefined(args?.emitCloseEvent) && args?.emitCloseEvent) {
emitRightDrawerCloseEvent();
}
}, },
[], [],
); );

View File

@ -157,26 +157,26 @@ export const useListenClickOutside = <T extends Element>({
.getLoadable(getClickOutsideListenerMouseDownHappenedState) .getLoadable(getClickOutsideListenerMouseDownHappenedState)
.getValue(); .getValue();
if (mode === ClickOutsideMode.compareHTMLRef) { const clickedElement = event.target as HTMLElement;
const clickedElement = event.target as HTMLElement; let isClickedOnExcluded = false;
let isClickedOnExcluded = false; let currentElement: HTMLElement | null = clickedElement;
let currentElement: HTMLElement | null = clickedElement;
while (currentElement) { while (currentElement) {
const currentClassList = currentElement.classList; const currentClassList = currentElement.classList;
isClickedOnExcluded = isClickedOnExcluded =
excludeClassNames?.some((className) => excludeClassNames?.some((className) =>
currentClassList.contains(className), currentClassList.contains(className),
) ?? false; ) ?? false;
if (isClickedOnExcluded) { if (isClickedOnExcluded) {
break; break;
}
currentElement = currentElement.parentElement;
} }
currentElement = currentElement.parentElement;
}
if (mode === ClickOutsideMode.compareHTMLRef) {
const clickedOnAtLeastOneRef = refs const clickedOnAtLeastOneRef = refs
.filter((ref) => !!ref.current) .filter((ref) => !!ref.current)
.some((ref) => ref.current?.contains(event.target as Node)); .some((ref) => ref.current?.contains(event.target as Node));
@ -244,7 +244,8 @@ export const useListenClickOutside = <T extends Element>({
!clickedOnAtLeastOneRef && !clickedOnAtLeastOneRef &&
!isMouseDownInside && !isMouseDownInside &&
isListening && isListening &&
hasMouseDownHappened; hasMouseDownHappened &&
!isClickedOnExcluded;
if (CLICK_OUTSIDE_DEBUG_MODE) { if (CLICK_OUTSIDE_DEBUG_MODE) {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
@ -255,6 +256,7 @@ export const useListenClickOutside = <T extends Element>({
isMouseDownInside, isMouseDownInside,
isListening, isListening,
hasMouseDownHappened, hasMouseDownHappened,
isClickedOnExcluded,
hotkeyScope, hotkeyScope,
enabled, enabled,
event, event,