Skip to content

Commit 6ecc15f

Browse files
fix(mobile): restrict row highlighting to pointer input (#11863)
1 parent 9ea892e commit 6ecc15f

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

‎apps/mobile/src/components/RowPressable.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { GestureDetector } from "react-native-gesture-handler";
55
import { cn } from "../lib/cn";
66
import { useHoverGesture } from "../lib/useHoverGesture";
77

8-
/** Shared row feedback, layered over the background so selection stays visible. */
8+
/** Pointer feedback layered over selection. Touch-down may be the start of a scroll. */
99
export function RowPressable({
1010
children,
1111
className,
@@ -24,7 +24,7 @@ export function RowPressable({
2424
<View
2525
pointerEvents="none"
2626
className={cn("absolute inset-0", interactionClassName)}
27-
style={{ opacity: props.disabled ? 0 : pressed ? 0.2 : hovered ? 0.1 : 0 }}
27+
style={{ opacity: props.disabled || !hovered ? 0 : pressed ? 0.2 : 0.1 }}
2828
/>
2929
{children}
3030
</>

‎apps/mobile/src/lib/useHoverGesture.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { useMemo, useState } from "react";
2-
import { Gesture } from "react-native-gesture-handler";
2+
import { Gesture, PointerType } from "react-native-gesture-handler";
33

44
/** Uses native hover recognition without React Native's optional pointer-event flags. */
55
export function useHoverGesture(disabled = false) {
@@ -12,8 +12,10 @@ export function useHoverGesture(disabled = false) {
1212
// Observe hover without competing with row taps, scrolling, or swipe actions.
1313
.cancelsTouchesInView(false)
1414
.runOnJS(true)
15-
.onBegin(() => {
16-
setHovered(true);
15+
.onBegin((event) => {
16+
setHovered(
17+
event.pointerType === PointerType.MOUSE || event.pointerType === PointerType.STYLUS,
18+
);
1719
})
1820
.onFinalize(() => {
1921
setHovered(false);

0 commit comments

Comments
 (0)