diff --git a/src/components/SasquatchGuide.tsx b/src/components/SasquatchGuide.tsx index 8324025..88ac9e3 100644 --- a/src/components/SasquatchGuide.tsx +++ b/src/components/SasquatchGuide.tsx @@ -365,6 +365,10 @@ export function SasquatchGuide({ message, onDismiss }: SasquatchGuideProps) { const dragRef = useRef(null); const dragStart = useRef<{ mx: number; my: number; bx: number; by: number } | null>(null); const dragMoved = useRef(false); + // Timestamp of the last panel-open via tap. Used to ignore stray + // close/minimize events that fire from the same tap on mobile. + const justOpenedRef = useRef(0); + const recentlyOpened = () => Date.now() - justOpenedRef.current < 400; // Dragging handlers const onPointerDown = useCallback((e: React.PointerEvent) => { @@ -389,13 +393,27 @@ export function SasquatchGuide({ message, onDismiss }: SasquatchGuideProps) { }, [setDragPos]); const onPointerUp = useCallback((e: React.PointerEvent) => { - if (dragRef.current) dragRef.current.releasePointerCapture(e.pointerId); + // Suppress the synthesized mouse "click" that follows a touch pointerup. + // Without this, on mobile WebViews the ghost click lands on whatever element + // is now under the finger (the panel unmounts the bubble the instant we + // open) and can immediately re-close the panel — the "opens then closes" + // bug. + e.preventDefault(); + e.stopPropagation(); + try { + if (dragRef.current) dragRef.current.releasePointerCapture(e.pointerId); + } catch { + // releasePointerCapture can throw if the element is unmounting — ignore. + } const wasDrag = dragMoved.current; dragStart.current = null; dragMoved.current = false; setTimeout(() => setIsDragging(false), 50); if (!wasDrag) { - // Always open the panel — even on pages without a context message + // Always open the panel — even on pages without a context message. + // Set a short "just opened" lock so a stray follow-up event from the same + // tap can't immediately minimize/close it. + justOpenedRef.current = Date.now(); setIsMinimized(false); setIsVisible(true); } @@ -739,7 +757,7 @@ Instructions:
{/* Minimize — shrinks to draggable bubble */} {/* Close — hides the panel entirely */}