diff --git a/src/app/features/tasks/short-syntax.spec.ts b/src/app/features/tasks/short-syntax.spec.ts index e440b9a50b..ecfab9a0ce 100644 --- a/src/app/features/tasks/short-syntax.spec.ts +++ b/src/app/features/tasks/short-syntax.spec.ts @@ -428,6 +428,28 @@ describe('shortSyntax', () => { }); }); + it('should work for edge case #3728', () => { + const t = { + ...TASK, + title: 'Test tag error #testing #someNewTag3', + tagIds: [], + }; + const r = shortSyntax(t, CONFIG, [ + ...ALL_TAGS, + { ...DEFAULT_TAG, id: 'testing_id', title: 'testing' }, + ]); + + expect(r).toEqual({ + newTagTitles: ['someNewTag3'], + remindAt: null, + projectId: undefined, + taskChanges: { + title: 'Test tag error', + tagIds: ['testing_id'], + }, + }); + }); + it('should not add new "asd #asd" tag when disabled', () => { const t = { ...TASK, diff --git a/src/app/features/tasks/store/short-syntax.effects.ts b/src/app/features/tasks/store/short-syntax.effects.ts index 05c9aa93f6..0138566517 100644 --- a/src/app/features/tasks/store/short-syntax.effects.ts +++ b/src/app/features/tasks/store/short-syntax.effects.ts @@ -156,7 +156,9 @@ export class ShortSyntaxEffects { } if (r.newTagTitles.length) { - actions.push(addNewTagsFromShortSyntax({ task, newTitles: r.newTagTitles })); + actions.push( + addNewTagsFromShortSyntax({ taskId: task.id, newTitles: r.newTagTitles }), + ); } if (tagIds && tagIds.length) { @@ -184,7 +186,7 @@ export class ShortSyntaxEffects { ofType(addNewTagsFromShortSyntax), // needed cause otherwise task gets the focus after blur & hide tap((v) => this._layoutService.hideAddTaskBar()), - concatMap(({ task, newTitles }) => { + concatMap(({ taskId, newTitles }) => { return this._matDialog .open(DialogConfirmComponent, { restoreFocus: true, @@ -205,7 +207,9 @@ export class ShortSyntaxEffects { }) .afterClosed() .pipe( - mergeMap((isConfirm: boolean) => { + // NOTE: it is important to get a fresh task here, since otherwise we might run into #3728 + withLatestFrom(this._taskService.getByIdOnce$(taskId)), + mergeMap(([isConfirm, task]) => { const actions: any[] = []; if (isConfirm) { const newTagIds = [...task.tagIds]; diff --git a/src/app/features/tasks/store/task.actions.ts b/src/app/features/tasks/store/task.actions.ts index ba01ae8b71..3eb0f9aaa2 100644 --- a/src/app/features/tasks/store/task.actions.ts +++ b/src/app/features/tasks/store/task.actions.ts @@ -259,7 +259,7 @@ export const addNewTagsFromShortSyntax = createAction( TaskActionTypes.AddNewTagsFromShortSyntax, props<{ - task: Task; + taskId: string; newTitles: string[]; }>(), );