From 389852ac17a8606266dd72483779cdef667ad8f9 Mon Sep 17 00:00:00 2001 From: Hikaru Y Date: Fri, 28 Apr 2023 10:39:50 +0900 Subject: [PATCH] Prevent MathJax editor from closing unexpectedly when selecting text (#2484) * Prevent MathJax editor from closing unexpectedly when selecting text * Revert "Prevent MathJax editor from closing unexpectedly when selecting text" This reverts commit b43d33a6de36d0af38933c6dae8bdd635294effd. * Prevent floating/overlay element from closing when selecting text Apply suggestions from code review. Use a 'mousedown' event instead of a 'click' event so that releasing the mouse button at the end of a text selection operation when the pointer is outside a floating/overlay element does not close it. Co-authored-by: Damien Elmes --------- Co-authored-by: Damien Elmes --- ts/components/WithFloating.svelte | 4 ++-- ts/components/WithOverlay.svelte | 4 ++-- ts/sveltelib/event-store.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ts/components/WithFloating.svelte b/ts/components/WithFloating.svelte index 50773fb83..462c08b9e 100644 --- a/ts/components/WithFloating.svelte +++ b/ts/components/WithFloating.svelte @@ -17,7 +17,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import isClosingClick from "../sveltelib/closing-click"; import isClosingKeyup from "../sveltelib/closing-keyup"; import type { EventPredicateResult } from "../sveltelib/event-predicate"; - import { documentClick, documentKeyup } from "../sveltelib/event-store"; + import { documentKeyup, documentMouseDown } from "../sveltelib/event-store"; import portal from "../sveltelib/portal"; import type { PositioningCallback } from "../sveltelib/position/auto-update"; import autoUpdate from "../sveltelib/position/auto-update"; @@ -134,7 +134,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html return; } - const closingClick = isClosingClick(documentClick, { + const closingClick = isClosingClick(documentMouseDown, { reference, floating, inside: closeOnInsideClick, diff --git a/ts/components/WithOverlay.svelte b/ts/components/WithOverlay.svelte index ec5c50b9c..b06d2ce34 100644 --- a/ts/components/WithOverlay.svelte +++ b/ts/components/WithOverlay.svelte @@ -17,7 +17,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import isClosingClick from "../sveltelib/closing-click"; import isClosingKeyup from "../sveltelib/closing-keyup"; import type { EventPredicateResult } from "../sveltelib/event-predicate"; - import { documentClick, documentKeyup } from "../sveltelib/event-store"; + import { documentKeyup, documentMouseDown } from "../sveltelib/event-store"; import type { PositioningCallback } from "../sveltelib/position/auto-update"; import autoUpdate from "../sveltelib/position/auto-update"; import type { PositionAlgorithm } from "../sveltelib/position/position-algorithm"; @@ -105,7 +105,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html return; } - const closingClick = isClosingClick(documentClick, { + const closingClick = isClosingClick(documentMouseDown, { reference, floating, inside: closeOnInsideClick, diff --git a/ts/sveltelib/event-store.ts b/ts/sveltelib/event-store.ts index 0930919f4..2b7f3ef5a 100644 --- a/ts/sveltelib/event-store.ts +++ b/ts/sveltelib/event-store.ts @@ -34,7 +34,7 @@ function eventStore>( export default eventStore; -const documentClick = eventStore(document, "click", MouseEvent); +const documentMouseDown = eventStore(document, "mousedown", MouseEvent); const documentKeyup = eventStore(document, "keyup", KeyboardEvent); -export { documentClick, documentKeyup }; +export { documentKeyup, documentMouseDown };