Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/components/Search/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentCo
lastSearchType,
setLastSearchType,
} = useSearchContext();
const {selectionMode} = useMobileSelectionMode(false);
const {selectionMode} = useMobileSelectionMode();
const [offset, setOffset] = useState(0);

const {type, status, sortBy, sortOrder, hash} = queryJSON;
Expand Down Expand Up @@ -509,7 +509,6 @@ function Search({queryJSON, onSearchListScroll, isSearchScreenFocused, contentCo
? item.transactions.some((transaction) => selectedTransactions[transaction.keyForList]?.isSelected)
: !!item.isSelected
}
shouldAutoTurnOff={false}
onScroll={onSearchListScroll}
onContentSizeChange={onContentSizeChange}
canSelectMultiple={type !== CONST.SEARCH.DATA_TYPES.CHAT && canSelectMultiple}
Expand Down
5 changes: 2 additions & 3 deletions src/components/SelectionListWithModal/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,12 @@ import CONST from '@src/CONST';
type SelectionListWithModalProps<TItem extends ListItem> = BaseSelectionListProps<TItem> & {
turnOnSelectionModeOnLongPress?: boolean;
onTurnOnSelectionMode?: (item: TItem | null) => void;
shouldAutoTurnOff?: boolean;
isSelected?: (item: TItem) => boolean;
isScreenFocused?: boolean;
};

function SelectionListWithModal<TItem extends ListItem>(
{turnOnSelectionModeOnLongPress, onTurnOnSelectionMode, onLongPressRow, isScreenFocused = false, sections, shouldAutoTurnOff, isSelected, ...rest}: SelectionListWithModalProps<TItem>,
{turnOnSelectionModeOnLongPress, onTurnOnSelectionMode, onLongPressRow, isScreenFocused = false, sections, isSelected, ...rest}: SelectionListWithModalProps<TItem>,
ref: ForwardedRef<SelectionListHandle>,
) {
const [isModalVisible, setIsModalVisible] = useState(false);
Expand All @@ -33,7 +32,7 @@ function SelectionListWithModal<TItem extends ListItem>(
const {isSmallScreenWidth} = useResponsiveLayout();
const isFocused = useIsFocused();

const {selectionMode} = useMobileSelectionMode(shouldAutoTurnOff);
const {selectionMode} = useMobileSelectionMode();
// Check if selection should be on when the modal is opened
const wasSelectionOnRef = useRef(false);
// Keep track of the number of selected items to determine if we should turn off selection mode
Expand Down
7 changes: 2 additions & 5 deletions src/hooks/useMobileSelectionMode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,12 @@ import {useOnyx} from 'react-native-onyx';
import {turnOffMobileSelectionMode} from '@libs/actions/MobileSelectionMode';
import ONYXKEYS from '@src/ONYXKEYS';

export default function useMobileSelectionMode(shouldAutoTurnOff = true) {
export default function useMobileSelectionMode() {
const [selectionMode] = useOnyx(ONYXKEYS.MOBILE_SELECTION_MODE);

useEffect(() => {
if (!shouldAutoTurnOff) {
return;
}
turnOffMobileSelectionMode();
}, [shouldAutoTurnOff]);
}, []);

return {selectionMode};
}
Loading