From ca8e4f8273ce273ea17de397719f9914c055df4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Tue, 9 Apr 2024 15:19:02 +0200 Subject: [PATCH 1/2] save white-characters-only drafts --- src/libs/DraftCommentUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/DraftCommentUtils.ts b/src/libs/DraftCommentUtils.ts index 325da93d235e..bf7a47316b04 100644 --- a/src/libs/DraftCommentUtils.ts +++ b/src/libs/DraftCommentUtils.ts @@ -25,7 +25,7 @@ function getDraftComment(reportID: string): OnyxEntry | null | undefined * A valid draft comment is a non-empty string. */ function isValidDraftComment(comment?: string | null): boolean { - return !!comment?.trim(); + return !!comment; } /** @@ -41,7 +41,7 @@ function hasValidDraftComment(reportID: string): boolean { function prepareDraftComment(comment: string | null) { // logical OR is used to convert empty string to null // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - return comment?.trim() || null; + return comment ?? null; } export {getDraftComment, isValidDraftComment, hasValidDraftComment, prepareDraftComment}; From 6d3096b82062ff4619047f59935b04a847d03e21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Miko=C5=82ajczak?= Date: Tue, 9 Apr 2024 16:04:47 +0200 Subject: [PATCH 2/2] replace nullish with OR fallback --- src/libs/DraftCommentUtils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libs/DraftCommentUtils.ts b/src/libs/DraftCommentUtils.ts index bf7a47316b04..b3cb32498725 100644 --- a/src/libs/DraftCommentUtils.ts +++ b/src/libs/DraftCommentUtils.ts @@ -36,12 +36,12 @@ function hasValidDraftComment(reportID: string): boolean { } /** - * Prepares a draft comment by trimming it and returning null if it's empty. + * Prepares a draft comment by returning null if it's empty. */ function prepareDraftComment(comment: string | null) { // logical OR is used to convert empty string to null // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing - return comment ?? null; + return comment || null; } export {getDraftComment, isValidDraftComment, hasValidDraftComment, prepareDraftComment};