From ddc886fdc13c623d1c7f7e3e18f8dd9a91ab2596 Mon Sep 17 00:00:00 2001 From: Timothy Jaeryang Baek Date: Sun, 30 Aug 2026 21:39:13 -0400 Subject: [PATCH] refac --- .../components/common/MobileSwipePanel.svelte | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/lib/components/common/MobileSwipePanel.svelte b/src/lib/components/common/MobileSwipePanel.svelte index f4ba515db0..bc76eeaa31 100644 --- a/src/lib/components/common/MobileSwipePanel.svelte +++ b/src/lib/components/common/MobileSwipePanel.svelte @@ -67,6 +67,15 @@ ); }; + const hasTextSelection = () => { + if (typeof window === 'undefined') { + return false; + } + + const selection = window.getSelection(); + return !!selection && !selection.isCollapsed; + }; + const canScrollHorizontally = (target: EventTarget | null, dx: number) => { if (!(target instanceof Element) || dx === 0 || typeof window === 'undefined') { return false; @@ -161,7 +170,7 @@ }; const onTouchStart = (e: TouchEvent) => { - if (!enabled || e.touches.length !== 1 || shouldSkipSwipe(e.target)) { + if (!enabled || e.touches.length !== 1 || shouldSkipSwipe(e.target) || hasTextSelection()) { return; } @@ -205,6 +214,11 @@ const absY = Math.abs(dy); if (!locked) { + if (hasTextSelection()) { + cancelSwipe(); + return; + } + if ((direction === 'open' && dx > 0) || (direction === 'close' && dx < 0)) { swipeProgress = Math.max(0, Math.min(1, startProgress + dx / panelWidth)); }