mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 06:22:22 -04:00
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:
parent
894b7862e3
commit
e35a938368
3 changed files with 6 additions and 6 deletions
|
@ -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,
|
||||||
|
|
|
@ -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,
|
||||||
|
|
|
@ -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 };
|
||||||
|
|
Loading…
Reference in a new issue