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 b43d33a6de.

* 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 <dae@users.noreply.github.com>

---------

Co-authored-by: Damien Elmes <dae@users.noreply.github.com>
This commit is contained in:
Hikaru Y 2023-04-28 10:39:50 +09:00 committed by GitHub
parent 894b7862e3
commit e35a938368
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View file

@ -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 isClosingClick from "../sveltelib/closing-click";
import isClosingKeyup from "../sveltelib/closing-keyup"; import isClosingKeyup from "../sveltelib/closing-keyup";
import type { EventPredicateResult } from "../sveltelib/event-predicate"; 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 portal from "../sveltelib/portal";
import type { PositioningCallback } from "../sveltelib/position/auto-update"; import type { PositioningCallback } from "../sveltelib/position/auto-update";
import autoUpdate 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; return;
} }
const closingClick = isClosingClick(documentClick, { const closingClick = isClosingClick(documentMouseDown, {
reference, reference,
floating, floating,
inside: closeOnInsideClick, inside: closeOnInsideClick,

View file

@ -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 isClosingClick from "../sveltelib/closing-click";
import isClosingKeyup from "../sveltelib/closing-keyup"; import isClosingKeyup from "../sveltelib/closing-keyup";
import type { EventPredicateResult } from "../sveltelib/event-predicate"; 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 type { PositioningCallback } from "../sveltelib/position/auto-update";
import autoUpdate from "../sveltelib/position/auto-update"; import autoUpdate from "../sveltelib/position/auto-update";
import type { PositionAlgorithm } from "../sveltelib/position/position-algorithm"; 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; return;
} }
const closingClick = isClosingClick(documentClick, { const closingClick = isClosingClick(documentMouseDown, {
reference, reference,
floating, floating,
inside: closeOnInsideClick, inside: closeOnInsideClick,

View file

@ -34,7 +34,7 @@ function eventStore<T extends EventTarget, K extends keyof EventTargetToMap<T>>(
export default eventStore; export default eventStore;
const documentClick = eventStore(document, "click", MouseEvent); const documentMouseDown = eventStore(document, "mousedown", MouseEvent);
const documentKeyup = eventStore(document, "keyup", KeyboardEvent); const documentKeyup = eventStore(document, "keyup", KeyboardEvent);
export { documentClick, documentKeyup }; export { documentKeyup, documentMouseDown };