Skip to content

Commit 425804a

Browse files
authored
Merge pull request #44070 from truph01/fix/43565
Fix: Unable to create a task with a long description
2 parents b021195 + 24c85b7 commit 425804a

File tree

3 files changed

+11
-16
lines changed

3 files changed

+11
-16
lines changed

src/pages/tasks/NewTaskDescriptionPage.tsx

+4-7
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as ErrorUtils from '@libs/ErrorUtils';
1717
import Navigation from '@libs/Navigation/Navigation';
1818
import type {NewTaskNavigatorParamList} from '@libs/Navigation/types';
1919
import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser';
20+
import * as ReportUtils from '@libs/ReportUtils';
2021
import updateMultilineInputRange from '@libs/updateMultilineInputRange';
2122
import variables from '@styles/variables';
2223
import * as TaskActions from '@userActions/Task';
@@ -48,13 +49,9 @@ function NewTaskDescriptionPage({task}: NewTaskDescriptionPageProps) {
4849

4950
const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_TASK_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.NEW_TASK_FORM> => {
5051
const errors = {};
51-
52-
if (values.taskDescription.length > CONST.DESCRIPTION_LIMIT) {
53-
ErrorUtils.addErrorMessage(
54-
errors,
55-
'taskDescription',
56-
translate('common.error.characterLimitExceedCounter', {length: values.taskDescription.length, limit: CONST.DESCRIPTION_LIMIT}),
57-
);
52+
const taskDescriptionLength = ReportUtils.getCommentLength(values.taskDescription);
53+
if (taskDescriptionLength > CONST.DESCRIPTION_LIMIT) {
54+
ErrorUtils.addErrorMessage(errors, 'taskDescription', translate('common.error.characterLimitExceedCounter', {length: taskDescriptionLength, limit: CONST.DESCRIPTION_LIMIT}));
5855
}
5956

6057
return errors;

src/pages/tasks/NewTaskDetailsPage.tsx

+4-6
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import * as ErrorUtils from '@libs/ErrorUtils';
1717
import Navigation from '@libs/Navigation/Navigation';
1818
import type {NewTaskNavigatorParamList} from '@libs/Navigation/types';
1919
import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser';
20+
import * as ReportUtils from '@libs/ReportUtils';
2021
import playSound, {SOUNDS} from '@libs/Sound';
2122
import variables from '@styles/variables';
2223
import * as TaskActions from '@userActions/Task';
@@ -61,12 +62,9 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) {
6162
} else if (values.taskTitle.length > CONST.TITLE_CHARACTER_LIMIT) {
6263
ErrorUtils.addErrorMessage(errors, 'taskTitle', translate('common.error.characterLimitExceedCounter', {length: values.taskTitle.length, limit: CONST.TITLE_CHARACTER_LIMIT}));
6364
}
64-
if (values.taskDescription.length > CONST.DESCRIPTION_LIMIT) {
65-
ErrorUtils.addErrorMessage(
66-
errors,
67-
'taskDescription',
68-
translate('common.error.characterLimitExceedCounter', {length: values.taskDescription.length, limit: CONST.DESCRIPTION_LIMIT}),
69-
);
65+
const taskDescriptionLength = ReportUtils.getCommentLength(values.taskDescription);
66+
if (taskDescriptionLength > CONST.DESCRIPTION_LIMIT) {
67+
ErrorUtils.addErrorMessage(errors, 'taskDescription', translate('common.error.characterLimitExceedCounter', {length: taskDescriptionLength, limit: CONST.DESCRIPTION_LIMIT}));
7068
}
7169

7270
return errors;

src/pages/tasks/TaskDescriptionPage.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti
3636
const validate = useCallback(
3737
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_TASK_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.EDIT_TASK_FORM> => {
3838
const errors = {};
39-
40-
if (values?.description && values.description?.length > CONST.DESCRIPTION_LIMIT) {
41-
ErrorUtils.addErrorMessage(errors, 'description', translate('common.error.characterLimitExceedCounter', {length: values.description.length, limit: CONST.DESCRIPTION_LIMIT}));
39+
const taskDescriptionLength = ReportUtils.getCommentLength(values.description);
40+
if (values?.description && taskDescriptionLength > CONST.DESCRIPTION_LIMIT) {
41+
ErrorUtils.addErrorMessage(errors, 'description', translate('common.error.characterLimitExceedCounter', {length: taskDescriptionLength, limit: CONST.DESCRIPTION_LIMIT}));
4242
}
4343

4444
return errors;

0 commit comments

Comments
 (0)