From 345485dbf3c7911faf2388891045b8712f0592a3 Mon Sep 17 00:00:00 2001 From: Rushat Gabhane Date: Mon, 28 Aug 2023 18:47:55 +0530 Subject: [PATCH] Revert "use optional chaining" This reverts commit 8433620609eba73f8174fdf58bbb361cd7bf69e2. --- .../ReportActionCompose.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js index 9121cc4efeaa..523f98264f34 100644 --- a/src/pages/home/report/ReportActionCompose/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose/ReportActionCompose.js @@ -183,7 +183,7 @@ function ReportActionCompose({ if (!isKeyboardVisibleWhenShowingModalRef.current) { return; } - composerRef?.current?.focus(true); + composerRef.current.focus(true); isKeyboardVisibleWhenShowingModalRef.current = false; }, []); @@ -197,9 +197,9 @@ function ReportActionCompose({ const onAddActionPressed = useCallback(() => { if (!willBlurTextInputOnTapOutside) { - isKeyboardVisibleWhenShowingModalRef.current = composerRef?.current?.isFocused(); + isKeyboardVisibleWhenShowingModalRef.current = composerRef.current.isFocused(); } - composerRef?.current?.blur(); + composerRef.current.blur(); }, []); const updateShouldShowSuggestionMenuToFalse = useCallback(() => { @@ -218,7 +218,7 @@ function ReportActionCompose({ // We don't really care about saving the draft the user was typing // We need to make sure an empty draft gets saved instead debouncedSaveReportComment.cancel(); - const newComment = composerRef?.current?.prepareCommentAndResetComposer(); + const newComment = composerRef.current.prepareCommentAndResetComposer(); Report.addAttachment(reportID, file, newComment); setTextInputShouldClear(false); }, @@ -250,7 +250,7 @@ function ReportActionCompose({ // We need to make sure an empty draft gets saved instead debouncedSaveReportComment.cancel(); - const newComment = composerRef?.current?.prepareCommentAndResetComposer(); + const newComment = composerRef.current.prepareCommentAndResetComposer(); if (!newComment) { return; } @@ -403,8 +403,13 @@ function ReportActionCompose({ {DeviceCapabilities.canUseTouchScreen() && isMediumScreenWidth ? null : ( composerRef?.current?.focus(true)} - onEmojiSelected={(...args) => composerRef?.current?.replaceSelectionWithText(...args)} + onModalHide={() => { + if (composerRef === null || composerRef.current === null) { + return; + } + composerRef.current.focus(true); + }} + onEmojiSelected={(...args) => composerRef.current.replaceSelectionWithText(...args)} emojiPickerID={report.reportID} /> )}