Skip to content

Commit

Permalink
Merge pull request #43153 from tienifr/fix/42552
Browse files Browse the repository at this point in the history
fix: not found page when select draft policy
  • Loading branch information
Hayata Suenaga authored Jul 8, 2024
2 parents 3ff8225 + 0e25c05 commit 22a122f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 4 deletions.
14 changes: 13 additions & 1 deletion src/components/MoneyRequestConfirmationList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,18 @@ function MoneyRequestConfirmationList({
],
);

const shouldDisableParticipant = (participant: Participant): boolean => {
if (ReportUtils.isDraftReport(participant.reportID)) {
return true;
}

if (!participant.isInvoiceRoom && !participant.isPolicyExpenseChat && !participant.isSelfDM && ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1)) {
return true;
}

return false;
};

const sections = useMemo(() => {
const options: Array<SectionListDataType<MoneyRequestConfirmationListItem>> = [];
if (isTypeSplit) {
Expand All @@ -553,7 +565,7 @@ function MoneyRequestConfirmationList({
const formattedSelectedParticipants = selectedParticipants.map((participant) => ({
...participant,
isSelected: false,
isDisabled: !participant.isInvoiceRoom && !participant.isPolicyExpenseChat && !participant.isSelfDM && ReportUtils.isOptimisticPersonalDetail(participant.accountID ?? -1),
isInteractive: !shouldDisableParticipant(participant),
}));
options.push({
title: translate('common.to'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function GenericPressable(
onPressOut,
accessible = true,
fullDisabled = false,
interactive = true,
...rest
}: PressableProps,
ref: PressableRef,
Expand Down Expand Up @@ -67,14 +68,17 @@ function GenericPressable(
* Returns the cursor style based on the state of Pressable
*/
const cursorStyle = useMemo(() => {
if (!interactive) {
return styles.cursorDefault;
}
if (shouldUseDisabledCursor) {
return styles.cursorDisabled;
}
if ([rest.accessibilityRole, rest.role].includes(CONST.ROLE.PRESENTATION)) {
return styles.cursorText;
}
return styles.cursorPointer;
}, [styles, shouldUseDisabledCursor, rest.accessibilityRole, rest.role]);
}, [styles, shouldUseDisabledCursor, rest.accessibilityRole, rest.role, interactive]);

const onLongPressHandler = useCallback(
(event: GestureResponderEvent) => {
Expand All @@ -98,7 +102,7 @@ function GenericPressable(

const onPressHandler = useCallback(
(event?: GestureResponderEvent | KeyboardEvent) => {
if (isDisabled) {
if (isDisabled || !interactive) {
return;
}
if (!onPress) {
Expand All @@ -113,7 +117,7 @@ function GenericPressable(
}
return onPress(event);
},
[shouldUseHapticsOnPress, onPress, nextFocusRef, ref, isDisabled],
[shouldUseHapticsOnPress, onPress, nextFocusRef, ref, isDisabled, interactive],
);

const voidOnPressHandler = useCallback(
Expand Down
6 changes: 6 additions & 0 deletions src/components/Pressable/GenericPressable/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ type PressableProps = RNPressableProps &
* Specifies if the pressable responder should be disabled
*/
fullDisabled?: boolean;

/**
* Whether the menu item should be interactive at all
* e.g., show disabled cursor when disabled
*/
interactive?: boolean;
};

type PressableRef = ForwardedRef<HTMLDivElement | View | RNText | undefined>;
Expand Down
1 change: 1 addition & 0 deletions src/components/SelectionList/BaseListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function BaseListItem<TItem extends ListItem>({
onSelectRow(item);
}}
disabled={isDisabled && !item.isSelected}
interactive={item.isInteractive}
accessibilityLabel={item.text ?? ''}
role={CONST.ROLE.BUTTON}
hoverDimmingValue={1}
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 @@ -81,6 +81,9 @@ type ListItem = {
/** Whether this option is disabled for selection */
isDisabled?: boolean | null;

/** Whether this item should be interactive at all */
isInteractive?: boolean;

/** List title is bold by default. Use this props to customize it */
isBold?: boolean;

Expand Down

0 comments on commit 22a122f

Please sign in to comment.