Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not found page when select draft policy #43153

Merged
merged 6 commits into from
Jul 8, 2024
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
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 @@ -79,6 +79,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
Loading