From c594c1efa7be595608f70861b39a07c104ec8e84 Mon Sep 17 00:00:00 2001 From: mmargaryan Date: Tue, 13 Aug 2024 18:15:33 +0400 Subject: [PATCH] fix: replace mousedown with pointerdown in click outside container --- .../click-outside-container/click-outside-container.tsx | 4 ++-- packages/core/test/data-editor.test.tsx | 3 ++- packages/core/test/test-utils.tsx | 8 ++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/core/src/internal/click-outside-container/click-outside-container.tsx b/packages/core/src/internal/click-outside-container/click-outside-container.tsx index 6ce195be0..0a27bccac 100644 --- a/packages/core/src/internal/click-outside-container/click-outside-container.tsx +++ b/packages/core/src/internal/click-outside-container/click-outside-container.tsx @@ -9,13 +9,13 @@ export default class ClickOutsideContainer extends React.PureComponent { public componentDidMount() { document.addEventListener("touchend", this.clickOutside, true); - document.addEventListener("mousedown", this.clickOutside, true); + document.addEventListener("pointerdown", this.clickOutside, true); document.addEventListener("contextmenu", this.clickOutside, true); } public componentWillUnmount() { document.removeEventListener("touchend", this.clickOutside, true); - document.removeEventListener("mousedown", this.clickOutside, true); + document.removeEventListener("pointerdown", this.clickOutside, true); document.removeEventListener("contextmenu", this.clickOutside, true); } diff --git a/packages/core/test/data-editor.test.tsx b/packages/core/test/data-editor.test.tsx index 097c8e967..b042e58ba 100644 --- a/packages/core/test/data-editor.test.tsx +++ b/packages/core/test/data-editor.test.tsx @@ -20,6 +20,7 @@ import { prep, sendClick, sendTouchClick, + sendPointerClick, getCellCenterPositionForDefaultGrid, Context, standardBeforeEach, @@ -1559,7 +1560,7 @@ describe("data-editor", () => { const overlay = screen.getByDisplayValue("j"); expect(document.body.contains(overlay)).toBe(true); - sendClick(canvas, { + sendPointerClick(canvas, { clientX: 300, // Col B clientY: 36 + 32 * 5 + 16, // Row 1 (0 indexed) }); diff --git a/packages/core/test/test-utils.tsx b/packages/core/test/test-utils.tsx index 36568671a..c1d56e931 100644 --- a/packages/core/test/test-utils.tsx +++ b/packages/core/test/test-utils.tsx @@ -46,6 +46,14 @@ export function sendTouchClick(el: Element | Node | Document | Window, options?: }); } +export function sendPointerClick(el: Element | Node | Document | Window, options?: any): void { + fireEvent.pointerDown(el, options); + + fireEvent.pointerUp(el, options); + + fireEvent.click(el, options); +} + export const makeCell = (cell: Item): GridCell => { const [col, row] = cell; switch (col) {