Skip to content

Commit ed2d6b1

Browse files
committed
Delayed workspace member role empty state until debounced list clears
1 parent bfe78cf commit ed2d6b1

2 files changed

Lines changed: 7 additions & 8 deletions

File tree

src/components/SelectionListWithModal/index.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ import {isEmptyValueObject} from '@src/types/utils/EmptyObject';
2020
type SelectionListWithModalProps<TItem extends ListItem> = SelectionListProps<TItem> & {
2121
turnOnSelectionModeOnLongPress?: boolean;
2222
onTurnOnSelectionMode?: (item: TItem | null) => void;
23-
/** Show empty results immediately instead of waiting for the debounced list update. */
24-
shouldShowEmptyStateImmediately?: boolean;
2523
ref?: ForwardedRef<SelectionListHandle<TItem>>;
2624
};
2725

@@ -32,7 +30,6 @@ function SelectionListWithModal<TItem extends ListItem>({
3230
data,
3331
isSelected,
3432
selectedItems: selectedItemsProp,
35-
shouldShowEmptyStateImmediately = false,
3633
style: styleProp,
3734
ref,
3835
...rest
@@ -67,8 +64,7 @@ function SelectionListWithModal<TItem extends ListItem>({
6764
setDataState(filteredData);
6865
}, [filteredData, setDataState]);
6966

70-
const shouldUseDebouncedData = isFiltering && (!shouldShowEmptyStateImmediately || filteredData.length > 0);
71-
const displayData = shouldUseDebouncedData ? debouncedData : filteredData;
67+
const displayData = isFiltering ? debouncedData : filteredData;
7268

7369
const selectedItems = useMemo(
7470
() =>

src/pages/workspace/WorkspaceMembersPage.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
2424
import useConfirmModal from '@hooks/useConfirmModal';
2525
import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails';
2626
import useDebouncedAccessibilityAnnouncement from '@hooks/useDebouncedAccessibilityAnnouncement';
27+
import useDebouncedValue from '@hooks/useDebouncedValue';
2728
import useFilteredSelection from '@hooks/useFilteredSelection';
2829
import {useMemoizedLazyExpensifyIcons, useMemoizedLazyIllustrations} from '@hooks/useLazyAsset';
2930
import useLocalize from '@hooks/useLocalize';
@@ -618,9 +619,12 @@ function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembers
618619
const isPendingAddOrDelete =
619620
isOffline && data?.some((member) => member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || member.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.ADD);
620621
const shouldShowSearchBar = data.length > CONST.SEARCH_ITEM_LIMIT;
621-
const shouldShowEmptySearchMessage = !!shouldShowSearchBar && inputValue.length !== 0 && filteredData.length === 0;
622+
const debouncedFilteredData = useDebouncedValue(filteredData, CONST.TIMING.SEARCH_OPTION_LIST_DEBOUNCE_TIME);
623+
const hasNoFilteredMembers = filteredData.length === 0;
624+
const hasNoDebouncedFilteredMembers = debouncedFilteredData?.length === 0;
625+
const shouldShowEmptySearchMessage = !!shouldShowSearchBar && inputValue.length !== 0 && hasNoFilteredMembers;
622626
const shouldShowRoleFilter = data.length > 0;
623-
const shouldShowRoleFilterEmptyState = shouldShowRoleFilter && !!selectedRoleFilter && inputValue.length === 0 && filteredData.length === 0;
627+
const shouldShowRoleFilterEmptyState = shouldShowRoleFilter && !!selectedRoleFilter && inputValue.length === 0 && hasNoFilteredMembers && hasNoDebouncedFilteredMembers;
624628
const noResultsMessage = translate('common.noResultsFoundMatching', inputValue);
625629

626630
// SearchBar's built-in empty state also controls screen-reader announcements.
@@ -1002,7 +1006,6 @@ function WorkspaceMembersPage({personalDetails, route, policy}: WorkspaceMembers
10021006
shouldShowLoadingPlaceholder={isLoading}
10031007
onDismissError={dismissError}
10041008
shouldShowListEmptyContent={false}
1005-
shouldShowEmptyStateImmediately={shouldShowRoleFilterEmptyState}
10061009
showScrollIndicator={false}
10071010
shouldUseUserSkeletonView
10081011
shouldHeaderBeInsideList

0 commit comments

Comments
 (0)