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
4 changes: 2 additions & 2 deletions src/components/CategoryPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import RadioListItem from './SelectionList/ListItem/RadioListItem';
import SelectionList from './SelectionList/SelectionListWithSections';
import SelectionListWithSections from './SelectionList/SelectionListWithSections';
import type {ListItem} from './SelectionList/types';

type CategoryPickerProps = {
Expand Down Expand Up @@ -77,7 +77,7 @@ function CategoryPicker({selectedCategory, policyID, onSubmit, addBottomSafeArea
};

return (
<SelectionList
<SelectionListWithSections
sections={sections}
onSelectRow={onSubmit}
ListItem={RadioListItem}
Expand Down
4 changes: 2 additions & 2 deletions src/components/DestinationPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {getPerDiemCustomUnit} from '@libs/PolicyUtils';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import RadioListItem from './SelectionList/ListItem/RadioListItem';
import SelectionList from './SelectionList/SelectionListWithSections';
import SelectionListWithSections from './SelectionList/SelectionListWithSections';
import type {ListItem, SelectionListWithSectionsHandle} from './SelectionList/types';

type DestinationPickerProps = {
Expand Down Expand Up @@ -74,7 +74,7 @@ function DestinationPicker({selectedDestination, policyID, onSubmit, ref}: Desti
};

return (
<SelectionList
<SelectionListWithSections
ref={ref}
sections={sections}
shouldShowTextInput={shouldShowTextInput}
Expand Down
1 change: 0 additions & 1 deletion src/components/Search/SearchFiltersChatsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ function SearchFiltersChatsSelector({initialReportIDs, onFiltersUpdate, isScreen
const reportsFiltered = cleanSearchTerm === '' ? visibleReportsWhenSearchTermEmpty : visibleReportsWhenSearchTermNonEmpty;

sections.push({
title: undefined,
data: reportsFiltered,
sectionIndex: 1,
});
Expand Down
3 changes: 0 additions & 3 deletions src/components/Search/SearchFiltersParticipantsSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate,
chatOptions.currentUserOption.text = formattedName;

newSections.push({
title: '',
data: [chatOptions.currentUserOption],
sectionIndex: 0,
});
Expand All @@ -245,13 +244,11 @@ function SearchFiltersParticipantsSelector({initialAccountIDs, onFiltersUpdate,
);

newSections.push({
title: '',
data: filteredRecentReports,
sectionIndex: 1,
});

newSections.push({
title: '',
data: chatOptions.personalDetails,
sectionIndex: 2,
});
Expand Down
5 changes: 2 additions & 3 deletions src/components/Search/SearchMultipleSelectionPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useEffect, useState} from 'react';
import MultiSelectListItem from '@components/SelectionList/ListItem/MultiSelectListItem';
import SelectionList from '@components/SelectionList/SelectionListWithSections';
import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections';
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -98,7 +98,7 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
headerMessage: noResultsFound ? translate('common.noResultsFound') : undefined,
};
return (
<SelectionList
<SelectionListWithSections
sections={sections}
ListItem={MultiSelectListItem}
shouldShowTextInput={shouldShowTextInput}
Expand All @@ -108,7 +108,6 @@ function SearchMultipleSelectionPicker({items, initiallySelectedItems, pickerTit
shouldStopPropagation
shouldShowTooltips
canSelectMultiple
disableMaintainingScrollPosition
footerContent={
<SearchFilterPageFooterButtons
applyChanges={applyChanges}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Search/SearchSingleSelectionPicker.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {useEffect, useState} from 'react';
import SingleSelectListItem from '@components/SelectionList/ListItem/SingleSelectListItem';
import SelectionList from '@components/SelectionList/SelectionListWithSections';
import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections';
import useDebouncedState from '@hooks/useDebouncedState';
import useLocalize from '@hooks/useLocalize';
import Navigation from '@libs/Navigation/Navigation';
Expand Down Expand Up @@ -119,7 +119,7 @@ function SearchSingleSelectionPicker({
};

return (
<SelectionList
<SelectionListWithSections
sections={sections}
onSelectRow={onSelectItem}
ListItem={SingleSelectListItem}
Expand All @@ -128,7 +128,6 @@ function SearchSingleSelectionPicker({
textInputOptions={textInputOptions}
footerContent={shouldAutoSave ? undefined : footerContent}
showLoadingPlaceholder={!noResultsFound}
disableMaintainingScrollPosition
shouldUpdateFocusedIndex
shouldStopPropagation
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function BaseSelectionListWithSections<TItem extends ListItem>({
showListEmptyContent = true,
shouldShowTooltips = true,
disableKeyboardShortcuts = false,
disableMaintainingScrollPosition = false,
shouldShowTextInput,
shouldIgnoreFocus = false,
shouldStopPropagation = false,
Expand Down Expand Up @@ -362,7 +361,7 @@ function BaseSelectionListWithSections<TItem extends ListItem>({
ListFooterComponent={listFooterContent}
style={style?.listStyle}
contentContainerStyle={style?.contentContainerStyle}
maintainVisibleContentPosition={{disabled: disableMaintainingScrollPosition}}
maintainVisibleContentPosition={{disabled: true}}
/>
</>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/TagPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import type {PolicyTag, PolicyTags} from '@src/types/onyx';
import RadioListItem from './SelectionList/ListItem/RadioListItem';
import SelectionList from './SelectionList/SelectionListWithSections';
import SelectionListWithSections from './SelectionList/SelectionListWithSections';

type TagPickerProps = {
/** The policyID we are getting tags for */
Expand Down Expand Up @@ -135,7 +135,7 @@ function TagPicker({
const listItemTitleStyles = [styles.breakAll, styles.w100];

return (
<SelectionList
<SelectionListWithSections
sections={sections}
ListItem={RadioListItem}
style={{
Expand Down
4 changes: 2 additions & 2 deletions src/components/TaxPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {IOUAction} from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import RadioListItem from './SelectionList/ListItem/RadioListItem';
import SelectionList from './SelectionList/SelectionListWithSections';
import SelectionListWithSections from './SelectionList/SelectionListWithSections';

type TaxPickerProps = {
/** The selected tax rate of an expense */
Expand Down Expand Up @@ -104,7 +104,7 @@ function TaxPicker({selectedTaxRate = '', policyID, transactionID, onSubmit, act
};

return (
<SelectionList
<SelectionListWithSections
sections={sections}
shouldShowTextInput={shouldShowTextInput}
textInputOptions={textInputOptions}
Expand Down
5 changes: 2 additions & 3 deletions src/pages/EditReportFieldDropdown.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Icon from '@components/Icon';
import RadioListItem from '@components/SelectionList/ListItem/RadioListItem';
import SelectionList from '@components/SelectionList/SelectionListWithSections';
import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections';
import type {ListItem} from '@components/SelectionList/types';
import useDebouncedState from '@hooks/useDebouncedState';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
Expand Down Expand Up @@ -73,15 +73,14 @@ function EditReportFieldDropdown({onSubmit, fieldKey, fieldValue, fieldOptions}:
};

return (
<SelectionList
<SelectionListWithSections
sections={sections ?? []}
ListItem={RadioListItem}
shouldShowTextInput
textInputOptions={textInputOptions}
onSelectRow={(option) => onSubmit({[fieldKey]: !option?.text || fieldValue === option.text ? '' : option.text})}
initiallyFocusedItemKey={selectedOptionKey}
rightHandSideComponent={itemRightSideComponent}
disableMaintainingScrollPosition
/>
);
}
Expand Down
1 change: 0 additions & 1 deletion src/pages/InviteReportParticipantsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ function InviteReportParticipantsPage({report}: InviteReportParticipantsPageProp
showLoadingPlaceholder={!areOptionsInitialized || !didScreenTransitionEnd}
footerContent={footerContent}
onEndReached={onListEndReached}
disableMaintainingScrollPosition
/>
</ScreenWrapper>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, {useEffect, useMemo, useState} from 'react';
import React, {useEffect, useState} from 'react';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ CONSISTENCY-4 (docs)

The useMemo import is no longer used in this file after removing the useMemo wrapper around softExclusions calculation (line 68 in the diff).

Fix: Remove useMemo from the React import:

import React, {useEffect, useState} from 'react';

Please rate this suggestion with 👍 or 👎 to help us improve! Reactions are used to monitor reviewer efficiency.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that import was already removed. some kind of false positive here.

import {View} from 'react-native';
import type {SectionListData} from 'react-native';
import Button from '@components/Button';
import HeaderWithBackButton from '@components/HeaderWithBackButton';
import {useSession} from '@components/OnyxListItemProvider';
import ScreenWrapper from '@components/ScreenWrapper';
// eslint-disable-next-line no-restricted-imports
import SelectionList from '@components/SelectionListWithSections';
import InviteMemberListItem from '@components/SelectionListWithSections/InviteMemberListItem';
import type {Section} from '@components/SelectionListWithSections/types';
import InviteMemberListItem from '@components/SelectionList/ListItem/InviteMemberListItem';
import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections';
import type {Section} from '@components/SelectionList/SelectionListWithSections/types';
import Text from '@components/Text';
import useArchivedReportsIdSet from '@hooks/useArchivedReportsIdSet';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
Expand Down Expand Up @@ -38,7 +36,7 @@ import ONYXKEYS from '@src/ONYXKEYS';
import type {InvitedEmailsToAccountIDs} from '@src/types/onyx';
import type {BaseOnboardingWorkspaceInviteProps} from './types';

type Sections = SectionListData<OptionData, Section<OptionData>>;
type Sections = Array<Section<OptionData>>;

function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWorkspaceInviteProps) {
const styles = useThemeStyles();
Expand Down Expand Up @@ -68,10 +66,7 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
excludedUsers[login] = true;
}

const softExclusions = useMemo(
() => getSoftExclusionsForGuideAndAccountManager(policy, account?.accountManagerAccountID, personalDetails),
[policy, account?.accountManagerAccountID, personalDetails],
);
const softExclusions = getSoftExclusionsForGuideAndAccountManager(policy, account?.accountManagerAccountID, personalDetails);

const {searchTerm, debouncedSearchTerm, setSearchTerm, availableOptions, selectedOptions, selectedOptionsForDisplay, toggleSelection, areOptionsInitialized, searchOptions} =
useSearchSelector({
Expand All @@ -92,13 +87,13 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
searchInServer(debouncedSearchTerm);
}, [debouncedSearchTerm]);

const sections: Sections[] = [];
const sections: Sections = [];
if (areOptionsInitialized) {
// Selected options section
if (selectedOptionsForDisplay.length > 0) {
sections.push({
title: undefined,
data: selectedOptionsForDisplay,
sectionIndex: 0,
});
}

Expand All @@ -107,14 +102,15 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
sections.push({
title: translate('common.contacts'),
data: availableOptions.personalDetails,
sectionIndex: 1,
});
}

// User to invite section
if (availableOptions.userToInvite) {
sections.push({
title: undefined,
data: [availableOptions.userToInvite],
sectionIndex: 2,
});
}
}
Expand Down Expand Up @@ -205,6 +201,19 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
</View>
);

const textInputOptions = {
headerMessage,
label: translate('selectionList.nameEmailOrPhoneNumber'),
style: {
containerStyle: onboardingIsMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5,
headerMessageStyle: [onboardingIsMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5, styles.pb5],
},
onChangeText: (value: string) => {
setSearchTerm(value);
},
value: searchTerm,
};

return (
<ScreenWrapper
enableEdgeToEdgeBottomSafeAreaPadding
Expand All @@ -225,25 +234,22 @@ function BaseOnboardingWorkspaceInvite({shouldUseNativeStyles}: BaseOnboardingWo
<View style={[onboardingIsMediumOrLargerScreenWidth ? styles.mh8 : styles.mh5, onboardingIsMediumOrLargerScreenWidth ? styles.flexRow : styles.flexColumn, styles.mb5]}>
<Text style={[styles.textNormal, styles.colorMuted]}>{translate('onboarding.inviteMembers.subtitle')}</Text>
</View>
<SelectionList
listItemWrapperStyle={onboardingIsMediumOrLargerScreenWidth ? [styles.pl8, styles.pr8] : []}
textInputStyle={onboardingIsMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5}
sectionTitleStyles={onboardingIsMediumOrLargerScreenWidth ? styles.ph3 : undefined}
headerMessageStyle={[onboardingIsMediumOrLargerScreenWidth ? styles.ph8 : styles.ph5, styles.pb5]}
<SelectionListWithSections
canSelectMultiple
confirmButtonOptions={{
onConfirm: inviteUser,
}}
sections={sections}
ListItem={InviteMemberListItem}
textInputLabel={translate('selectionList.nameEmailOrPhoneNumber')}
textInputValue={searchTerm}
onChangeText={(value) => {
setSearchTerm(value);
}}
headerMessage={headerMessage}
onSelectRow={toggleSelection}
onConfirm={inviteUser}
showScrollIndicator
shouldShowTextInput
showLoadingPlaceholder={!areOptionsInitialized || !didScreenTransitionEnd}
shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()}
style={{
sectionTitleStyles: onboardingIsMediumOrLargerScreenWidth ? styles.ph3 : undefined,
listItemWrapperStyle: onboardingIsMediumOrLargerScreenWidth ? [styles.pl8, styles.pr8] : [],
}}
textInputOptions={textInputOptions}
footerContent={footerContent}
isLoadingNewOptions={!!isSearchingForReports}
addBottomSafeAreaPadding={isSmallScreenWidth}
Expand Down
1 change: 0 additions & 1 deletion src/pages/RoomInvitePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ function RoomInvitePage({
shouldPreventDefaultFocusOnSelectRow={!canUseTouchScreen()}
showLoadingPlaceholder={!areOptionsInitialized}
isLoadingNewOptions={!!isSearchingForReports}
disableMaintainingScrollPosition
shouldShowTextInput
canSelectMultiple
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ function SearchFiltersCardPage() {
showLoadingPlaceholder={
isLoadingOnyxValue(userCardListMetadata, workspaceCardFeedsMetadata, searchAdvancedFiltersFormMetadata, policiesMetadata) || !didScreenTransitionEnd
}
disableMaintainingScrollPosition
shouldStopPropagation
canSelectMultiple
/>
Expand Down
2 changes: 0 additions & 2 deletions src/pages/iou/request/MoneyRequestAccountantSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
)
) {
newSections.push({
title: undefined,
data: [chatOptions.userToInvite].map((participant) => {
const isPolicyExpenseChat = participant?.isPolicyExpenseChat ?? false;
return isPolicyExpenseChat
Expand Down Expand Up @@ -276,7 +275,6 @@ function MoneyRequestAccountantSelector({onFinish, onAccountantSelected, iouType
showLoadingPlaceholder={showLoadingPlaceholder}
isLoadingNewOptions={!!isSearchingForReports}
showListEmptyContent={shouldShowListEmptyContent}
disableMaintainingScrollPosition
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ function BaseShareLogList({onAttachLogToReport}: BaseShareLogListProps) {
onSelectRow={attachLogToReport}
shouldSingleExecuteRowSelect
shouldShowTextInput
disableMaintainingScrollPosition
textInputOptions={textInputOptions}
showLoadingPlaceholder={!didScreenTransitionEnd}
isLoadingNewOptions={!!isSearchingForReports}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import HeaderWithBackButton from '@components/HeaderWithBackButton';
import MenuItem from '@components/MenuItem';
import ScreenWrapper from '@components/ScreenWrapper';
import UserListItem from '@components/SelectionList/ListItem/UserListItem';
import SelectionList from '@components/SelectionList/SelectionListWithSections';
import Text from '@components/Text';
import SelectionListWithSections from '@components/SelectionList/SelectionListWithSections';
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
Expand Down Expand Up @@ -210,15 +210,14 @@ function VacationDelegatePage() {
</View>
) : (
<View style={[styles.flex1, styles.w100, styles.pRelative]}>
<SelectionList
<SelectionListWithSections
sections={areOptionsInitialized ? sections : []}
ListItem={UserListItem}
onSelectRow={onSelectRow}
textInputOptions={textInputOptions}
showLoadingPlaceholder={!areOptionsInitialized}
isLoadingNewOptions={!!isSearchingForReports}
onEndReached={onListEndReached}
disableMaintainingScrollPosition
shouldSingleExecuteRowSelect
shouldShowTextInput
/>
Expand Down
Loading
Loading