Skip to content

Commit

Permalink
Merge pull request #49970 from bernhardoj/fix/49537-holding-down-item…
Browse files Browse the repository at this point in the history
…-list-scrolls-the-list

Fix holding on a message in search page scrolls the page
  • Loading branch information
Beamanator authored Oct 2, 2024
2 parents 19a137d + 28b7891 commit c3b4a65
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function BaseSelectionList<TItem extends ListItem>(
onLongPressRow,
shouldShowTextInput = !!textInputLabel || !!textInputIconLeft,
shouldShowListEmptyContent = true,
shouldIgnoreFocus = false,
scrollEventThrottle,
contentContainerStyle,
}: BaseSelectionListProps<TItem>,
Expand Down Expand Up @@ -468,7 +469,7 @@ function BaseSelectionList<TItem extends ListItem>(
isAlternateTextMultilineSupported={isAlternateTextMultilineSupported}
alternateTextNumberOfLines={alternateTextNumberOfLines}
onFocus={() => {
if (isDisabled) {
if (shouldIgnoreFocus || isDisabled) {
return;
}
setFocusedIndex(normalizedIndex);
Expand Down
4 changes: 4 additions & 0 deletions src/components/SelectionList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, {forwardRef, useEffect, useState} from 'react';
import type {ForwardedRef} from 'react';
import {Keyboard} from 'react-native';
import * as Browser from '@libs/Browser';
import * as DeviceCapabilities from '@libs/DeviceCapabilities';
import BaseSelectionList from './BaseSelectionList';
import type {BaseSelectionListProps, ListItem, SelectionListHandle} from './types';
Expand Down Expand Up @@ -42,6 +43,9 @@ function SelectionList<TItem extends ListItem>({onScroll, ...props}: BaseSelecti
{...props}
ref={ref}
onScroll={onScroll ?? defaultOnScroll}
// Ignore the focus if it's caused by a touch event on mobile chrome.
// For example, a long press will trigger a focus event on mobile chrome.
shouldIgnoreFocus={Browser.isMobileChrome() && isScreenTouched}
/>
);
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/SelectionList/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ type BaseSelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Styles to apply to SectionList component */
sectionListStyle?: StyleProp<ViewStyle>;

/** Whether to ignore the focus event */
shouldIgnoreFocus?: boolean;

/** Whether focus event should be delayed */
shouldDelayFocus?: boolean;

Expand Down

0 comments on commit c3b4a65

Please sign in to comment.