diff --git a/front/src/modules/ui/hooks/__tests__/useListenClickOutsideArrayOfRef.test.tsx b/front/src/modules/ui/hooks/__tests__/useListenClickOutsideArrayOfRef.test.tsx index b289994c9..a331c91f9 100644 --- a/front/src/modules/ui/hooks/__tests__/useListenClickOutsideArrayOfRef.test.tsx +++ b/front/src/modules/ui/hooks/__tests__/useListenClickOutsideArrayOfRef.test.tsx @@ -28,12 +28,12 @@ test('useListenClickOutsideArrayOfRef hook works in dom mode', async () => { const inside2 = getByText('Inside 2'); const outside = getByText('Outside'); - fireEvent.click(inside); + fireEvent.mouseUp(inside); expect(onOutsideClick).toHaveBeenCalledTimes(0); - fireEvent.click(inside2); + fireEvent.mouseUp(inside2); expect(onOutsideClick).toHaveBeenCalledTimes(0); - fireEvent.click(outside); + fireEvent.mouseUp(outside); expect(onOutsideClick).toHaveBeenCalledTimes(1); }); diff --git a/front/src/modules/ui/hooks/useListenClickOutsideArrayOfRef.ts b/front/src/modules/ui/hooks/useListenClickOutsideArrayOfRef.ts index eba805689..71bcbb22c 100644 --- a/front/src/modules/ui/hooks/useListenClickOutsideArrayOfRef.ts +++ b/front/src/modules/ui/hooks/useListenClickOutsideArrayOfRef.ts @@ -43,8 +43,6 @@ export function useListenClickOutsideArrayOfRef({ const clientY = 'clientY' in event ? event.clientY : event.touches[0].clientY; - console.log(clientX, clientY, x, y, width, height); - if ( clientX < x || clientX > x + width || @@ -64,12 +62,12 @@ export function useListenClickOutsideArrayOfRef({ const hasAtLeastOneRefDefined = refs.some((ref) => isDefined(ref.current)); if (hasAtLeastOneRefDefined) { - document.addEventListener('click', handleClickOutside); + document.addEventListener('mouseup', handleClickOutside); document.addEventListener('touchend', handleClickOutside); } return () => { - document.removeEventListener('click', handleClickOutside); + document.removeEventListener('mouseup', handleClickOutside); document.removeEventListener('touchend', handleClickOutside); }; }, [refs, callback, mode]); diff --git a/front/src/pages/companies/__stories__/Company.stories.tsx b/front/src/pages/companies/__stories__/Company.stories.tsx index 6d05ca115..0f9eb2ffe 100644 --- a/front/src/pages/companies/__stories__/Company.stories.tsx +++ b/front/src/pages/companies/__stories__/Company.stories.tsx @@ -1,7 +1,7 @@ import { getOperationName } from '@apollo/client/utilities'; import { expect } from '@storybook/jest'; import type { Meta, StoryObj } from '@storybook/react'; -import { within } from '@storybook/testing-library'; +import { fireEvent, within } from '@storybook/testing-library'; import { graphql } from 'msw'; import { @@ -71,7 +71,7 @@ export const EditNote: Story = { ).toBeInTheDocument(); const workspaceName = await canvas.findByText('Twenty'); - await workspaceName.click(); + await fireEvent.mouseUp(workspaceName); expect(await canvas.queryByDisplayValue('My very first note')).toBeNull();