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: 3 additions & 1 deletion src/components/SelectionList/BaseSelectionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function BaseSelectionList<TItem extends ListItem>({
shouldSingleExecuteRowSelect = false,
shouldPreventDefaultFocusOnSelectRow = false,
shouldShowTextInput = !!textInputOptions?.label,
shouldClearInputOnSelect = false,
shouldHighlightSelectedItem = true,
shouldUseDefaultRightHandSideCheckmark,
shouldDisableHoverStyle = false,
Expand Down Expand Up @@ -187,7 +188,7 @@ function BaseSelectionList<TItem extends ListItem>({
return;
}
if (canSelectMultiple) {
if (shouldShowTextInput) {
if (shouldShowTextInput && shouldClearInputOnSelect) {
textInputOptions?.onChangeText?.('');
} else if (isSmallScreenWidth) {
if (!item.isDisabledCheckbox) {
Expand All @@ -211,6 +212,7 @@ function BaseSelectionList<TItem extends ListItem>({
shouldUpdateFocusedIndex,
onSelectRow,
shouldShowTextInput,
shouldClearInputOnSelect,
shouldPreventDefaultFocusOnSelectRow,
isSmallScreenWidth,
textInputOptions,
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 @@ -151,6 +151,9 @@ type SelectionListProps<TItem extends ListItem> = Partial<ChildrenProps> & {
/** Whether to show the text input */
shouldShowTextInput?: boolean;

/** Whether to clear the text input when a row is selected */
shouldClearInputOnSelect?: boolean;

/** Whether to highlight the selected item */
shouldHighlightSelectedItem?: boolean;

Expand Down
19 changes: 10 additions & 9 deletions src/pages/settings/Wallet/ShareBankAccount/ShareBankAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function ShareBankAccount({route}: ShareBankAccountProps) {
// Apply search filter if there's a search term
if (debouncedSearchTerm) {
const searchValue = getSearchValueForPhoneOrEmail(debouncedSearchTerm, countryCode).toLowerCase();
adminsToDisplay = tokenizedSearch(admins, searchValue, (option) => [option.text ?? '', option.alternateText ?? '']);
adminsToDisplay = tokenizedSearch(adminsToDisplay, searchValue, (option) => [option.text ?? '', option.alternateText ?? '']);
}

return adminsToDisplay;
Expand All @@ -127,17 +127,17 @@ function ShareBankAccount({route}: ShareBankAccountProps) {
const adminsList = getAdminList();

const toggleSelectAll = () => {
const hasSelectedOptions = selectedOptions.length > 0;
setIsAlertVisible(false);

if (hasSelectedOptions) {
setSelectedOptions([]);
const areAllFilteredOptionsSelected = adminsList.length > 0 && adminsList.every((admin) => selectedOptions.some((selected) => selected.login === admin.login));

if (areAllFilteredOptionsSelected) {
const filteredLogins = new Set(adminsList.map((admin) => admin.login));
setSelectedOptions(selectedOptions.filter((option) => !filteredLogins.has(option.login)));
} else {
const selectedAllOptions = adminsList?.map((member) => ({
...member,
isSelected: true,
}));
setSelectedOptions(selectedAllOptions);
const existingLogins = new Set(selectedOptions.map((option) => option.login));
const newSelections = adminsList.filter((admin) => !existingLogins.has(admin.login)).map((admin) => ({...admin, isSelected: true}));
setSelectedOptions([...selectedOptions, ...newSelections]);
}
};

Expand Down Expand Up @@ -198,6 +198,7 @@ function ShareBankAccount({route}: ShareBankAccountProps) {
}
ListItem={UserListItem}
shouldUseDefaultRightHandSideCheckmark
onCheckboxPress={toggleOption}
onSelectRow={toggleOption}
footerContent={
<FormAlertWithSubmitButton
Expand Down
4 changes: 1 addition & 3 deletions src/pages/settings/Wallet/WalletPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ function WalletPage() {
type: CONST.PAYMENT_METHODS.DEBIT_CARD,
};
}
if (accountData?.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS) {
setShouldShowShareButton(accountData?.state === CONST.BANK_ACCOUNT.STATE.OPEN);
}
setShouldShowShareButton(accountData?.type === CONST.BANK_ACCOUNT.TYPE.BUSINESS && accountData?.state === CONST.BANK_ACCOUNT.STATE.OPEN);
setPaymentMethod({
isSelectedPaymentMethodDefault: !!isDefault,
selectedPaymentMethod: accountData ?? {},
Expand Down
Loading