Skip to content

Commit

Permalink
fix enable checkbox for optimistic user on workspace members page
Browse files Browse the repository at this point in the history
  • Loading branch information
nkdengineer committed Nov 7, 2024
1 parent afa7b33 commit c47ecdd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/SelectionList/TableListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function TableListItem<TItem extends ListItem>({
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
disabled={isDisabled || item.isDisabledCheckbox}
disabled={(isDisabled && !item.shouldPreventDisableCheckboxIfDisabled) || item.isDisabledCheckbox}
onPress={handleCheckboxPress}
style={[styles.cursorUnset, StyleUtils.getCheckboxPressableStyle(), item.isDisabledCheckbox && styles.cursorDisabled, styles.mr3, item.cursorStyle]}
>
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 @@ -191,6 +191,9 @@ type ListItem = {

/** The style to override the default appearance */
itemStyle?: StyleProp<ViewStyle>;

/** Whether to prevent list items from being disabled */
shouldPreventDisableCheckboxIfDisabled?: boolean;
};

type TransactionListItemType = ListItem &
Expand Down
4 changes: 4 additions & 0 deletions src/pages/workspace/WorkspaceMembersPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,10 @@ function WorkspaceMembersPage({personalDetails, route, policy, currentUserPerson
isDisabled:
!!details.isOptimisticPersonalDetail ||
(isPolicyAdmin && (policyEmployee.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isEmptyObject(policyEmployee.errors))),
shouldPreventDisableCheckboxIfDisabled: !(
isPolicyAdmin &&
(policyEmployee.pendingAction === CONST.RED_BRICK_ROAD_PENDING_ACTION.DELETE || !isEmptyObject(policyEmployee.errors))
),
cursorStyle: details.isOptimisticPersonalDetail ? styles.cursorDefault : {},
text: formatPhoneNumber(PersonalDetailsUtils.getDisplayNameOrDefault(details)),
alternateText: formatPhoneNumber(details?.login ?? ''),
Expand Down

0 comments on commit c47ecdd

Please sign in to comment.