Skip to content

Commit

Permalink
Merge pull request #34398 from Expensify/tgolen-refactor-composerside…
Browse files Browse the repository at this point in the history
…loading

Load parent report action from withOnyx in ComposerWithSuggestions
  • Loading branch information
thienlnam authored Jan 16, 2024
2 parents 5802cda + da54b6c commit 8e2fb67
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ function ComposerWithSuggestions({
const maxComposerLines = isSmallScreenWidth ? CONST.COMPOSER.MAX_LINES_SMALL_SCREEN : CONST.COMPOSER.MAX_LINES;

const isEmptyChat = useMemo(() => _.size(reportActions) === 1, [reportActions]);
const parentAction = ReportActionsUtils.getParentReportAction(report);
const shouldAutoFocus = !modal.isVisible && (shouldFocusInputOnScreenFocus || (isEmptyChat && !ReportActionsUtils.isTransactionThread(parentAction))) && shouldShowComposeInput;
const parentReportAction = lodashGet(parentReportActions, [report.parentReportActionID]);
const shouldAutoFocus = !modal.isVisible && (shouldFocusInputOnScreenFocus || (isEmptyChat && !ReportActionsUtils.isTransactionThread(parentReportAction))) && shouldShowComposeInput;

const valueRef = useRef(value);
valueRef.current = value;
Expand Down Expand Up @@ -344,9 +344,6 @@ function ComposerWithSuggestions({
const valueLength = valueRef.current.length;
if (e.key === CONST.KEYBOARD_SHORTCUTS.ARROW_UP.shortcutKey && textInputRef.current.selectionStart === 0 && valueLength === 0 && !ReportUtils.chatIncludesChronos(report)) {
e.preventDefault();

const parentReportActionID = lodashGet(report, 'parentReportActionID', '');
const parentReportAction = lodashGet(parentReportActions, [parentReportActionID], {});
const lastReportAction = _.find(
[...reportActions, parentReportAction],
(action) => ReportUtils.canEditReportAction(action) && !ReportActionsUtils.isMoneyRequestAction(action),
Expand All @@ -356,7 +353,7 @@ function ComposerWithSuggestions({
}
}
},
[isKeyboardShown, isSmallScreenWidth, parentReportActions, report, reportActions, reportID, handleSendMessage, suggestionsRef, valueRef],
[isKeyboardShown, isSmallScreenWidth, parentReportAction, report, reportActions, reportID, handleSendMessage, suggestionsRef, valueRef],
);

const onChangeText = useCallback(
Expand Down

0 comments on commit 8e2fb67

Please sign in to comment.