DEV: Improve checking for selected text (#30967)

After you've selected and deselected text, `selection.rangeCount` will
return `true` on future events. Checking for `selection.toString` is
more robust.

Followup to f1bdd86a8c9bec03b962167c37963b1d11d0e5ea
This commit is contained in:
Penar Musaraj 2025-02-07 12:13:39 -05:00 committed by GitHub
parent 6595b11e25
commit 54a52e5691
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -14,8 +14,7 @@ export function setupComposerPosition(editor) {
applyBehaviorTransformer("composer-position:editor-touch-move", () => {
const notScrollable = editor.scrollHeight <= editor.clientHeight;
const selection = window.getSelection();
if (notScrollable && selection.rangeCount === 0) {
if (notScrollable && selection.toString() === "") {
event.preventDefault();
event.stopPropagation();
}