Skip to content

Commit d2845e6

Browse files
committed
fix(quick-capture): initialize default filename when input is empty
1 parent 4387854 commit d2845e6

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/components/features/quick-capture/modals/MinimalQuickCaptureModalWithSwitch.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ export class MinimalQuickCaptureModal extends BaseQuickCaptureModal {
3737
private targetFileEl: HTMLDivElement | null = null;
3838
private editorContainer: HTMLElement | null = null;
3939

40-
constructor(app: App, plugin: TaskProgressBarPlugin, metadata?: TaskMetadata) {
40+
constructor(
41+
app: App,
42+
plugin: TaskProgressBarPlugin,
43+
metadata?: TaskMetadata,
44+
) {
4145
// Default to checkbox mode for task creation
4246
super(app, plugin, "checkbox", metadata);
4347

@@ -228,6 +232,10 @@ export class MinimalQuickCaptureModal extends BaseQuickCaptureModal {
228232
},
229233
});
230234

235+
// Initialize customFileName with resolved path so file-mode saves work
236+
// even when user doesn't edit the input
237+
this.taskMetadata.customFileName = resolvedPath;
238+
231239
// Update the customFileName when input changes
232240
this.fileNameInput.addEventListener("input", () => {
233241
if (this.fileNameInput) {
@@ -660,9 +668,11 @@ export class MinimalQuickCaptureModal extends BaseQuickCaptureModal {
660668

661669
// Add tags (ensure they start with # but don't double-add)
662670
if (this.taskMetadata.tags && this.taskMetadata.tags.length > 0) {
663-
metadata.push(...this.taskMetadata.tags.map((tag) =>
664-
tag.startsWith("#") ? tag : `#${tag}`
665-
));
671+
metadata.push(
672+
...this.taskMetadata.tags.map((tag) =>
673+
tag.startsWith("#") ? tag : `#${tag}`,
674+
),
675+
);
666676
}
667677

668678
// Add metadata to content

src/components/features/quick-capture/modals/QuickCaptureModalWithSwitch.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import {
3434
} from "./BaseQuickCaptureModal";
3535
import { FileNameInput } from "../components/FileNameInput";
3636
import { formatDate as formatDateSmart } from "@/utils/date/date-utils";
37+
import { processDateTemplates } from "@/utils/file/file-operations";
3738

3839
const LAST_USED_MODE_KEY = "task-genius.lastUsedQuickCaptureMode";
3940

@@ -295,6 +296,16 @@ export class QuickCaptureModal extends BaseQuickCaptureModal {
295296
},
296297
);
297298

299+
// Initialize customFileName with default value if not already set
300+
// This ensures the file mode save logic works even when user doesn't modify the input
301+
if (!this.taskMetadata.customFileName) {
302+
const defaultTemplate =
303+
this.plugin.settings.quickCapture.defaultFileNameTemplate ||
304+
"{{DATE:YYYY-MM-DD}} - Task";
305+
this.taskMetadata.customFileName =
306+
processDateTemplates(defaultTemplate);
307+
}
308+
298309
// Set initial value if exists
299310
if (this.taskMetadata.customFileName) {
300311
this.fileNameInput.setValue(this.taskMetadata.customFileName);

0 commit comments

Comments
 (0)