Skip to content

Commit

Permalink
Merge pull request #52302 from QichenZhu/fix/51246
Browse files Browse the repository at this point in the history
Fix fullscreen video controls difficult to click
  • Loading branch information
Gonals authored Nov 20, 2024
2 parents 9f83a41 + e258618 commit b52f41d
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions src/components/Attachments/AttachmentCarousel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {MutableRefObject} from 'react';
import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react';
import type {ListRenderItemInfo} from 'react-native';
import {Keyboard, PixelRatio, View} from 'react-native';
import type {GestureType} from 'react-native-gesture-handler';
import type {ComposedGesture, GestureType} from 'react-native-gesture-handler';
import {Gesture, GestureDetector} from 'react-native-gesture-handler';
import {useOnyx} from 'react-native-onyx';
import Animated, {scrollTo, useAnimatedRef, useSharedValue} from 'react-native-reanimated';
Expand Down Expand Up @@ -38,6 +38,19 @@ const viewabilityConfig = {

const MIN_FLING_VELOCITY = 500;

type DeviceAwareGestureDetectorProps = {
canUseTouchScreen: boolean;
gesture: ComposedGesture | GestureType;
children: React.ReactNode;
};

function DeviceAwareGestureDetector({canUseTouchScreen, gesture, children}: DeviceAwareGestureDetectorProps) {
// Don't render GestureDetector on non-touchable devices to prevent unexpected pointer event capture.
// This issue is left out on touchable devices since finger touch works fine.
// See: https://github.com/Expensify/App/issues/51246
return canUseTouchScreen ? <GestureDetector gesture={gesture}>{children}</GestureDetector> : children;
}

function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibility, type, accountID, onClose, attachmentLink}: AttachmentCarouselProps) {
const theme = useTheme();
const {translate} = useLocalize();
Expand Down Expand Up @@ -290,7 +303,10 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
cancelAutoHideArrow={cancelAutoHideArrows}
/>
<AttachmentCarouselPagerContext.Provider value={context}>
<GestureDetector gesture={pan}>
<DeviceAwareGestureDetector
canUseTouchScreen={canUseTouchScreen}
gesture={pan}
>
<Animated.FlatList
keyboardShouldPersistTaps="handled"
horizontal
Expand All @@ -309,7 +325,7 @@ function AttachmentCarousel({report, source, onNavigate, setDownloadButtonVisibi
viewabilityConfig={viewabilityConfig}
onViewableItemsChanged={updatePage}
/>
</GestureDetector>
</DeviceAwareGestureDetector>
</AttachmentCarouselPagerContext.Provider>

<CarouselActions onCycleThroughAttachments={cycleThroughAttachments} />
Expand Down

0 comments on commit b52f41d

Please sign in to comment.