From 1fd9c592e2342487f9b4530e9edc5b6fa96fc7f1 Mon Sep 17 00:00:00 2001 From: Alf Eaton Date: Tue, 25 Feb 2025 10:43:32 +0000 Subject: [PATCH] Ensure that lastClickEvent is set before handling doubleClick (#23865) GitOrigin-RevId: 1f080e62e95dc71cec6bcf2f5c9e0cb8bd5f5e2c --- .../js/features/source-editor/extensions/bracket-matching.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/services/web/frontend/js/features/source-editor/extensions/bracket-matching.ts b/services/web/frontend/js/features/source-editor/extensions/bracket-matching.ts index 17f000de6a..c14b144e6e 100644 --- a/services/web/frontend/js/features/source-editor/extensions/bracket-matching.ts +++ b/services/web/frontend/js/features/source-editor/extensions/bracket-matching.ts @@ -84,13 +84,13 @@ const chooseEventHandler = () => { } // Store and use the previous click event, as the "dblclick" event can have the wrong position - let lastClickEvent: MouseEvent + let lastClickEvent: MouseEvent | null = null return EditorView.domEventHandlers({ click(evt, view) { if (evt.detail === 1) { lastClickEvent = evt - } else if (evt.detail === 2) { + } else if (evt.detail === 2 && lastClickEvent) { return handleDoubleClick(lastClickEvent, view) } },