fix: edge case when creating new tags together with existing tags in short syntax

This commit is contained in:
Johannes Millan 2024-12-07 14:39:17 +01:00
parent cd9df17954
commit c1d608a080
3 changed files with 30 additions and 4 deletions

View file

@ -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,

View file

@ -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];

View file

@ -259,7 +259,7 @@ export const addNewTagsFromShortSyntax = createAction(
TaskActionTypes.AddNewTagsFromShortSyntax,
props<{
task: Task;
taskId: string;
newTitles: string[];
}>(),
);