Skip to content

Commit bdfe4c0

Browse files
committed
refactor: ! Remove activeFlatpickrInstance from EditTask
Tested use of Escape key manually, with just Modal open, and with native date-picker open
1 parent 115f70f commit bdfe4c0

File tree

1 file changed

+0
-22
lines changed

1 file changed

+0
-22
lines changed

src/Obsidian/TaskModal.ts

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { App, Modal } from 'obsidian';
2-
import type flatpickr from 'flatpickr';
32

43
import EditTask from '../ui/EditTask.svelte';
54
import type { Task } from '../Task/Task';
@@ -10,7 +9,6 @@ export class TaskModal extends Modal {
109
public readonly task: Task;
1110
public readonly onSubmit: (updatedTasks: Task[]) => void;
1211
public readonly allTasks: Task[];
13-
private activeFlatpickrInstance: flatpickr.Instance | null = null;
1412

1513
constructor({
1614
app,
@@ -28,13 +26,6 @@ export class TaskModal extends Modal {
2826
this.task = task;
2927
this.allTasks = allTasks;
3028
this.onSubmit = (updatedTasks: Task[]) => {
31-
if (this.activeFlatpickrInstance) {
32-
// Ignore onSubmit if the date-picker is open:
33-
// For some unknown reason, making the date-picker lunched from a Button
34-
// caused the modal to be automatically submitted before the user had
35-
// even seen the date picker.
36-
return;
37-
}
3829
updatedTasks.length && onSubmit(updatedTasks);
3930
this.close();
4031
};
@@ -78,17 +69,4 @@ export class TaskModal extends Modal {
7869
const { contentEl } = this;
7970
contentEl.empty();
8071
}
81-
82-
/**
83-
* Make sure that if the date picker is open, an Escape key only closes
84-
* the date-picker, and not the EditTask modal as well.
85-
*/
86-
public onEscapeKey(): void {
87-
if (this.activeFlatpickrInstance?.isOpen) {
88-
this.activeFlatpickrInstance.close();
89-
this.activeFlatpickrInstance = null;
90-
} else {
91-
this.close();
92-
}
93-
}
9472
}

0 commit comments

Comments
 (0)