From 15c593f68ee9d4aae97418e70a187c334d8386d3 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 4 Jul 2025 19:46:37 +0300 Subject: [PATCH] feat(views/table): automatically focus on title when creating new row --- .../widgets/view_widgets/table_view/index.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/view_widgets/table_view/index.ts b/apps/client/src/widgets/view_widgets/table_view/index.ts index 12cd8d742..f130b440c 100644 --- a/apps/client/src/widgets/view_widgets/table_view/index.ts +++ b/apps/client/src/widgets/view_widgets/table_view/index.ts @@ -72,6 +72,8 @@ export default class TableView extends ViewMode { private api?: Tabulator; private newAttribute?: Attribute; private persistentData: Record; + /** If set to a note ID, whenever the rows will be updated, the title of the note will be automatically focused for editing. */ + private noteIdToEdit?: string; constructor(args: ViewModeArgs) { super(args, "table"); @@ -188,7 +190,12 @@ export default class TableView extends ViewMode { if (parentNotePath) { note_create.createNote(parentNotePath, { activate: false - }); + }).then(({ note }) => { + if (!note) { + return; + } + this.noteIdToEdit = note.noteId; + }) } } @@ -242,6 +249,14 @@ export default class TableView extends ViewMode { const notes = await froca.getNotes(this.args.noteIds); const info = getPromotedAttributeInformation(this.parentNote); this.api.setData(await buildRowDefinitions(this.parentNote, notes, info)); + + if (this.noteIdToEdit) { + const row = this.api?.getRows(true).find(r => r.getData().noteId === this.noteIdToEdit); + if (row) { + row.getCell("title").edit(); + } + this.noteIdToEdit = undefined; + } } }