Skip to content

Commit

Permalink
Merge pull request #44070 from truph01/fix/43565
Browse files Browse the repository at this point in the history
Fix: Unable to create a task with a long description
  • Loading branch information
srikarparsi authored Jun 22, 2024
2 parents b021195 + 24c85b7 commit 425804a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
11 changes: 4 additions & 7 deletions src/pages/tasks/NewTaskDescriptionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {NewTaskNavigatorParamList} from '@libs/Navigation/types';
import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser';
import * as ReportUtils from '@libs/ReportUtils';
import updateMultilineInputRange from '@libs/updateMultilineInputRange';
import variables from '@styles/variables';
import * as TaskActions from '@userActions/Task';
Expand Down Expand Up @@ -48,13 +49,9 @@ function NewTaskDescriptionPage({task}: NewTaskDescriptionPageProps) {

const validate = (values: FormOnyxValues<typeof ONYXKEYS.FORMS.NEW_TASK_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.NEW_TASK_FORM> => {
const errors = {};

if (values.taskDescription.length > CONST.DESCRIPTION_LIMIT) {
ErrorUtils.addErrorMessage(
errors,
'taskDescription',
translate('common.error.characterLimitExceedCounter', {length: values.taskDescription.length, limit: CONST.DESCRIPTION_LIMIT}),
);
const taskDescriptionLength = ReportUtils.getCommentLength(values.taskDescription);
if (taskDescriptionLength > CONST.DESCRIPTION_LIMIT) {
ErrorUtils.addErrorMessage(errors, 'taskDescription', translate('common.error.characterLimitExceedCounter', {length: taskDescriptionLength, limit: CONST.DESCRIPTION_LIMIT}));
}

return errors;
Expand Down
10 changes: 4 additions & 6 deletions src/pages/tasks/NewTaskDetailsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as ErrorUtils from '@libs/ErrorUtils';
import Navigation from '@libs/Navigation/Navigation';
import type {NewTaskNavigatorParamList} from '@libs/Navigation/types';
import {parseHtmlToMarkdown} from '@libs/OnyxAwareParser';
import * as ReportUtils from '@libs/ReportUtils';
import playSound, {SOUNDS} from '@libs/Sound';
import variables from '@styles/variables';
import * as TaskActions from '@userActions/Task';
Expand Down Expand Up @@ -61,12 +62,9 @@ function NewTaskDetailsPage({task}: NewTaskDetailsPageProps) {
} else if (values.taskTitle.length > CONST.TITLE_CHARACTER_LIMIT) {
ErrorUtils.addErrorMessage(errors, 'taskTitle', translate('common.error.characterLimitExceedCounter', {length: values.taskTitle.length, limit: CONST.TITLE_CHARACTER_LIMIT}));
}
if (values.taskDescription.length > CONST.DESCRIPTION_LIMIT) {
ErrorUtils.addErrorMessage(
errors,
'taskDescription',
translate('common.error.characterLimitExceedCounter', {length: values.taskDescription.length, limit: CONST.DESCRIPTION_LIMIT}),
);
const taskDescriptionLength = ReportUtils.getCommentLength(values.taskDescription);
if (taskDescriptionLength > CONST.DESCRIPTION_LIMIT) {
ErrorUtils.addErrorMessage(errors, 'taskDescription', translate('common.error.characterLimitExceedCounter', {length: taskDescriptionLength, limit: CONST.DESCRIPTION_LIMIT}));
}

return errors;
Expand Down
6 changes: 3 additions & 3 deletions src/pages/tasks/TaskDescriptionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ function TaskDescriptionPage({report, currentUserPersonalDetails}: TaskDescripti
const validate = useCallback(
(values: FormOnyxValues<typeof ONYXKEYS.FORMS.EDIT_TASK_FORM>): FormInputErrors<typeof ONYXKEYS.FORMS.EDIT_TASK_FORM> => {
const errors = {};

if (values?.description && values.description?.length > CONST.DESCRIPTION_LIMIT) {
ErrorUtils.addErrorMessage(errors, 'description', translate('common.error.characterLimitExceedCounter', {length: values.description.length, limit: CONST.DESCRIPTION_LIMIT}));
const taskDescriptionLength = ReportUtils.getCommentLength(values.description);
if (values?.description && taskDescriptionLength > CONST.DESCRIPTION_LIMIT) {
ErrorUtils.addErrorMessage(errors, 'description', translate('common.error.characterLimitExceedCounter', {length: taskDescriptionLength, limit: CONST.DESCRIPTION_LIMIT}));
}

return errors;
Expand Down

0 comments on commit 425804a

Please sign in to comment.