fix(tasks): treat a missing title as blank instead of crashing isBlankTask #8713 (#8714)

This commit is contained in:
Myk 2026-07-03 11:13:26 +02:00 committed by GitHub
parent 108820695e
commit 8003a9e125
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -32,6 +32,12 @@ describe('isBlankTask', () => {
expect(isBlankTask(createTaskWithSubTasks())).toBe(true);
});
it('should be true (and not throw) when the title is missing entirely', () => {
const t = createTaskWithSubTasks() as any;
delete t.title;
expect(isBlankTask(t)).toBe(true);
});
it('should be true when the title is only whitespace', () => {
expect(isBlankTask(createTaskWithSubTasks({ title: ' ' }))).toBe(true);
});

View file

@ -13,7 +13,9 @@ import { Task, TaskWithSubTasks } from '../task.model';
export const isBlankTask = (task: Task | TaskWithSubTasks): boolean => {
const subTasks = (task as TaskWithSubTasks).subTasks;
return (
!task.title.trim() &&
// Corrupted/legacy tasks can lack a title entirely; treat that as blank
// instead of crashing the callers (e.g. the delete-undo snack effect).
!task.title?.trim() &&
!task.notes?.trim() &&
!task.timeSpent &&
!task.timeEstimate &&