Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ function MoneyRequestReportActionsList({
emojiReactions={actionEmojiReactions}
isReportArchived={isReportArchived}
draftMessage={matchingDraftMessageString}
isReverted={false}
isTryNewDotNVPDismissed={isTryNewDotNVPDismissed}
/>
);
Expand Down
6 changes: 3 additions & 3 deletions src/hooks/useReportScrollManager/index.native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ function useReportScrollManager(): ReportScrollManagerData {
* Scroll to the provided index.
*/
const scrollToIndex = useCallback(
(index: number) => {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
(index: number, isEditing?: boolean, viewPosition?: number) => {
if (!flatListRef?.current) {
return;
}

flatListRef.current.scrollToIndex({index});
flatListRef.current.scrollToIndex({index, viewPosition});
},
[flatListRef],
);
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useReportScrollManager/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ function useReportScrollManager(): ReportScrollManagerData {
* Scroll to the provided index. On non-native implementations we do not want to scroll when we are scrolling because
*/
const scrollToIndex = useCallback(
(index: number, isEditing?: boolean) => {
(index: number, isEditing?: boolean, viewPosition?: number) => {
if (!flatListRef?.current || isEditing) {
return;
}

flatListRef.current.scrollToIndex({index, animated: true});
flatListRef.current.scrollToIndex({index, animated: true, viewPosition});
},
[flatListRef],
);
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useReportScrollManager/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type {FlatListRefType} from '@pages/home/ReportScreenContext';

type ReportScrollManagerData = {
ref: FlatListRefType;
scrollToIndex: (index: number, isEditing?: boolean) => void;
scrollToIndex: (index: number, isEditing?: boolean, viewPosition?: number) => void;
scrollToBottom: () => void;
scrollToEnd: () => void;
scrollToOffset: (offset: number) => void;
Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/report/PureReportActionItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ type PureReportActionItemProps = {
/** Current user's account id */
currentUserAccountID?: number;

/** Whether the flatlist is reverted */
isReverted?: boolean;

/** The bank account list */
bankAccountList?: OnyxTypes.BankAccountList | undefined;
};
Expand Down Expand Up @@ -456,6 +459,7 @@ function PureReportActionItem({
shouldHighlight = false,
isTryNewDotNVPDismissed = false,
currentUserAccountID,
isReverted,
bankAccountList,
}: PureReportActionItemProps) {
const actionSheetAwareScrollViewContext = useContext(ActionSheetAwareScrollView.ActionSheetAwareScrollViewContext);
Expand Down Expand Up @@ -1492,6 +1496,7 @@ function PureReportActionItem({
(chatIncludesConcierge(report) && isBlockedFromConcierge(blockedFromConcierge)) || isArchivedNonExpenseReport(report, isArchivedRoom)
}
isGroupPolicyReport={!!report?.policyID && report.policyID !== CONST.POLICY.ID_FAKE}
isReverted={isReverted}
/>
)}
</AttachmentContext.Provider>
Expand Down
25 changes: 24 additions & 1 deletion src/pages/home/report/ReportActionItemMessageEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@
/** Whether report is from group policy */
isGroupPolicyReport: boolean;

/** Whether the flatlist is reverted */
isReverted?: boolean;

/** Reference to the outer element */
ref?: ForwardedRef<TextInput | HTMLTextAreaElement | undefined>;
};
Expand All @@ -106,6 +109,7 @@
index,
isGroupPolicyReport,
shouldDisableEmojiPicker = false,
isReverted = true,
ref,
}: ReportActionItemMessageEditProps) {
const [preferredSkinTone = CONST.EMOJI_DEFAULT_SKIN_TONE] = useOnyx(ONYXKEYS.PREFERRED_EMOJI_SKIN_TONE, {canBeMissing: true});
Expand Down Expand Up @@ -417,6 +421,25 @@
[cursorPositionValue, measureContainer, selection, isScrolling],
);

const scrollToIndex = useCallback(
(i: number, isEditing?: boolean, viewPosition?: number, shouldDelay = false) => {
if (shouldDelay) {
setTimeout(() => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment about this? and lets use the const value if we can use CONST.ANIMATED_TRANSITION

requestAnimationFrame(() => {
reportScrollManager.scrollToIndex(i, isEditing, viewPosition);
});
}, 400);
} else {
InteractionManager.runAfterInteractions(() => {

Check failure on line 433 in src/pages/home/report/ReportActionItemMessageEdit.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

`runAfterInteractions` is deprecated
requestAnimationFrame(() => {
reportScrollManager.scrollToIndex(i, isEditing, viewPosition);
});
});
}
},
[reportScrollManager],
);

useEffect(() => {
// We use the tag to store the native ID of the text input. Later, we use it in onSelectionChange to pick up the proper text input data.
tag.set(findNodeHandle(textInputRef.current) ?? -1);
Expand Down Expand Up @@ -513,7 +536,7 @@
// eslint-disable-next-line @typescript-eslint/no-deprecated
InteractionManager.runAfterInteractions(() => {
requestAnimationFrame(() => {
reportScrollManager.scrollToIndex(index, true);
scrollToIndex(index, true, isReverted ? 0 : 1, !isReverted);
endScrollBlock();
});
});
Expand Down
4 changes: 4 additions & 0 deletions src/pages/home/report/ReportActionItemParentAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ type ReportActionItemParentActionProps = {
/** User billing fund ID */
userBillingFundID: number | undefined;

/** Whether the flatlist is reverted */
isReverted?: boolean;
/** Did the user dismiss trying out NewDot? If true, it means they prefer using OldDot */
isTryNewDotNVPDismissed: boolean | undefined;

Expand All @@ -110,6 +112,7 @@ function ReportActionItemParentAction({
allEmojiReactions,
linkedTransactionRouteError,
userBillingFundID,
isReverted,
isTryNewDotNVPDismissed = false,
isReportArchived = false,
}: ReportActionItemParentActionProps) {
Expand Down Expand Up @@ -201,6 +204,7 @@ function ReportActionItemParentAction({
linkedTransactionRouteError={linkedTransactionRouteError}
userBillingFundID={userBillingFundID}
isTryNewDotNVPDismissed={isTryNewDotNVPDismissed}
isReverted={isReverted}
/>
</OfflineWithFeedback>
);
Expand Down
5 changes: 5 additions & 0 deletions src/pages/home/report/ReportActionsListItemRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ type ReportActionsListItemRendererProps = {
/** All emoji reactions collection */
allEmojiReactions?: OnyxCollection<ReportActionReactions>;

/** Whether the flatlist is reverted */
isReverted?: boolean;
/** Did the user dismiss trying out NewDot? If true, it means they prefer using OldDot */
isTryNewDotNVPDismissed: boolean | undefined;
/** Whether the report is archived */
Expand Down Expand Up @@ -128,6 +130,7 @@ function ReportActionsListItemRenderer({
personalDetails,
allDraftMessages,
allEmojiReactions,
isReverted,
isTryNewDotNVPDismissed = false,
isReportArchived = false,
}: ReportActionsListItemRendererProps) {
Expand Down Expand Up @@ -226,6 +229,7 @@ function ReportActionsListItemRenderer({
allEmojiReactions={allEmojiReactions}
linkedTransactionRouteError={linkedTransactionRouteError}
userBillingFundID={userBillingFundID}
isReverted={isReverted}
isTryNewDotNVPDismissed={isTryNewDotNVPDismissed}
isReportArchived={isReportArchived}
/>
Expand Down Expand Up @@ -259,6 +263,7 @@ function ReportActionsListItemRenderer({
emojiReactions={emojiReactions}
linkedTransactionRouteError={linkedTransactionRouteError}
userBillingFundID={userBillingFundID}
isReverted={isReverted}
isTryNewDotNVPDismissed={isTryNewDotNVPDismissed}
/>
);
Expand Down
Loading