From 21afb28006af4e01df3757abadbc5f09bf3e8217 Mon Sep 17 00:00:00 2001 From: 01zulfi <85733202+01zulfi@users.noreply.github.com> Date: Fri, 27 Jun 2025 11:50:43 +0500 Subject: [PATCH] core: don't generate headline title if title was set during note creation (#8266) Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com> --- packages/core/__tests__/notes.test.ts | 14 ++++++++++++++ packages/core/src/collections/notes.ts | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/core/__tests__/notes.test.ts b/packages/core/__tests__/notes.test.ts index 80c88f2a1..7a5fdc51d 100644 --- a/packages/core/__tests__/notes.test.ts +++ b/packages/core/__tests__/notes.test.ts @@ -205,6 +205,20 @@ test("note title with headline format should keep generating headline title unti })); }); +test("note title with headline format should not generate headline title if title was set during note creation", () => + noteTest({ title: "already set title" }).then(async ({ db, id }) => { + await db.settings.setTitleFormat("$headline$"); + await db.notes.add({ + id, + content: { + type: TEST_NOTE.content.type, + data: "

some note content

" + } + }); + const note = await db.notes.note(id); + expect(note?.title).toBe("already set title"); + })); + test("note should get headline from first paragraph in content", () => noteTest({ ...TEST_NOTE, diff --git a/packages/core/src/collections/notes.ts b/packages/core/src/collections/notes.ts index f95be2dee..a63ba4e4a 100644 --- a/packages/core/src/collections/notes.ts +++ b/packages/core/src/collections/notes.ts @@ -130,6 +130,7 @@ export class Notes implements ICollection { } if (!isUpdating || item.title === "") { + item.isGeneratedTitle = !Boolean(item.title); item.title = item.title || formatTitle( @@ -139,7 +140,6 @@ export class Notes implements ICollection { headlineTitle, this.totalNotes ); - item.isGeneratedTitle = true; } const currentNoteTitleFields = await this.db