TypeScript
fix(mobile): restrict row highlighting to pointer input (#11863)
Julius Marminge6ecc15fa25c8
diff --git a/apps/mobile/src/components/RowPressable.tsx b/apps/mobile/src/components/RowPressable.tsxindex 17f3d06599d..bd52fbe74f1 100644--- a/apps/mobile/src/components/RowPressable.tsx+++ b/apps/mobile/src/components/RowPressable.tsx@@ -5,7 +5,7 @@ import { GestureDetector } from "react-native-gesture-handler";import { cn } from "../lib/cn";import { useHoverGesture } from "../lib/useHoverGesture";-/** Shared row feedback, layered over the background so selection stays visible. */+/** Pointer feedback layered over selection. Touch-down may be the start of a scroll. */export function RowPressable({children,className,@@ -24,7 +24,7 @@ export function RowPressable({<ViewpointerEvents="none"className={cn("absolute inset-0", interactionClassName)}- style={{ opacity: props.disabled ? 0 : pressed ? 0.2 : hovered ? 0.1 : 0 }}+ style={{ opacity: props.disabled || !hovered ? 0 : pressed ? 0.2 : 0.1 }}/>{children}</>diff --git a/apps/mobile/src/lib/useHoverGesture.ts b/apps/mobile/src/lib/useHoverGesture.tsindex f06e4dd54ad..8be525c1b3c 100644--- a/apps/mobile/src/lib/useHoverGesture.ts+++ b/apps/mobile/src/lib/useHoverGesture.ts@@ -1,5 +1,5 @@import { useMemo, useState } from "react";-import { Gesture } from "react-native-gesture-handler";+import { Gesture, PointerType } from "react-native-gesture-handler";/** Uses native hover recognition without React Native's optional pointer-event flags. */export function useHoverGesture(disabled = false) {@@ -12,8 +12,10 @@ export function useHoverGesture(disabled = false) {// Observe hover without competing with row taps, scrolling, or swipe actions..cancelsTouchesInView(false).runOnJS(true)- .onBegin(() => {- setHovered(true);+ .onBegin((event) => {+ setHovered(+ event.pointerType === PointerType.MOUSE || event.pointerType === PointerType.STYLUS,+ );}).onFinalize(() => {setHovered(false);