From 3212c6ffed166559c8bea6269b697c721b8f8962 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Tue, 24 Oct 2023 17:07:46 -0500 Subject: [PATCH 1/4] fix: replace emojis on mount(both the main composer and edit composer) --- .../home/report/ReportActionCompose/SilentCommentUpdater.js | 5 +++++ src/pages/home/report/ReportActionItemMessageEdit.js | 2 ++ 2 files changed, 7 insertions(+) diff --git a/src/pages/home/report/ReportActionCompose/SilentCommentUpdater.js b/src/pages/home/report/ReportActionCompose/SilentCommentUpdater.js index 09f9d368bdcc..4347d6bde8b3 100644 --- a/src/pages/home/report/ReportActionCompose/SilentCommentUpdater.js +++ b/src/pages/home/report/ReportActionCompose/SilentCommentUpdater.js @@ -44,6 +44,11 @@ function SilentCommentUpdater({comment, commentRef, report, value, updateComment const {preferredLocale} = useLocalize(); const prevPreferredLocale = usePrevious(preferredLocale); + useEffect(() => { + updateComment(comment); + // eslint-disable-next-line react-hooks/exhaustive-deps -- We need to run this on mount + }, []); + useEffect(() => { // Value state does not have the same value as comment props when the comment gets changed from another tab. // In this case, we should synchronize the value between tabs. diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 4b73ce3b21db..6d6d7ff3becf 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -183,6 +183,8 @@ function ReportActionItemMessageEdit(props) { }); } + updateDraft(draft); + return () => { // Skip if the current report action is not active if (!isActive()) { From 6692d6040a53f42c0059407b61b8de308a03c5e1 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Tue, 24 Oct 2023 17:26:19 -0500 Subject: [PATCH 2/4] fix: call update draft when locale changes --- src/pages/home/report/ReportActionItemMessageEdit.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 6d6d7ff3becf..3dd9975a6f4c 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -183,8 +183,6 @@ function ReportActionItemMessageEdit(props) { }); } - updateDraft(draft); - return () => { // Skip if the current report action is not active if (!isActive()) { @@ -205,6 +203,11 @@ function ReportActionItemMessageEdit(props) { // eslint-disable-next-line react-hooks/exhaustive-deps -- this cleanup needs to be called only on unmount }, [props.action.reportActionID]); + useEffect(() => { + updateDraft(draft); + // eslint-disable-next-line react-hooks/exhaustive-deps -- run this only when language is changed + }, [props.action.reportActionID, preferredLocale]); + /** * Save the draft of the comment. This debounced so that we're not ceaselessly saving your edit. Saving the draft * allows one to navigate somewhere else and come back to the comment and still have it in edit mode. From 70329dbadbc674f8888adea73672874939e745ad Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Tue, 24 Oct 2023 17:35:21 -0500 Subject: [PATCH 3/4] fix: lint error --- src/pages/home/report/ReportActionItemMessageEdit.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 3dd9975a6f4c..56b525599e78 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -203,11 +203,6 @@ function ReportActionItemMessageEdit(props) { // eslint-disable-next-line react-hooks/exhaustive-deps -- this cleanup needs to be called only on unmount }, [props.action.reportActionID]); - useEffect(() => { - updateDraft(draft); - // eslint-disable-next-line react-hooks/exhaustive-deps -- run this only when language is changed - }, [props.action.reportActionID, preferredLocale]); - /** * Save the draft of the comment. This debounced so that we're not ceaselessly saving your edit. Saving the draft * allows one to navigate somewhere else and come back to the comment and still have it in edit mode. @@ -273,6 +268,11 @@ function ReportActionItemMessageEdit(props) { }, [props.action.message, debouncedSaveDraft, debouncedUpdateFrequentlyUsedEmojis, props.preferredSkinTone, preferredLocale], ); + + useEffect(() => { + updateDraft(draft); + // eslint-disable-next-line react-hooks/exhaustive-deps -- run this only when language is changed + }, [props.action.reportActionID, preferredLocale]); /** * Delete the draft of the comment being edited. This will take the comment out of "edit mode" with the old content. From 12b88e3e79ecd7045fd6ce523c772da0cb5ad135 Mon Sep 17 00:00:00 2001 From: s-alves10 Date: Tue, 24 Oct 2023 17:43:22 -0500 Subject: [PATCH 4/4] fix: prettier --- src/pages/home/report/ReportActionItemMessageEdit.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/home/report/ReportActionItemMessageEdit.js b/src/pages/home/report/ReportActionItemMessageEdit.js index 56b525599e78..8330aef5f23f 100644 --- a/src/pages/home/report/ReportActionItemMessageEdit.js +++ b/src/pages/home/report/ReportActionItemMessageEdit.js @@ -268,7 +268,7 @@ function ReportActionItemMessageEdit(props) { }, [props.action.message, debouncedSaveDraft, debouncedUpdateFrequentlyUsedEmojis, props.preferredSkinTone, preferredLocale], ); - + useEffect(() => { updateDraft(draft); // eslint-disable-next-line react-hooks/exhaustive-deps -- run this only when language is changed