Skip to content

editTaskLineModal() does not resolve its promise when user clicks Cancel #3656

@legaldrugdealer

Description

@legaldrugdealer

⚠️ Check issue is valid.

⚠️ Check that this issue hasn't been reported before.

Steps to reproduce

  1. Open Obsidian with the Tasks plugin enabled.
  2. Open the Developer Console (Ctrl+Shift+I / Cmd+Opt+I).
  3. Paste and run the following snippet:
const tasksApi = app.plugins.plugins["obsidian-tasks-plugin"].apiV1;
(async () => {
  console.log("[TEST] before modal");
  const result = await tasksApi.editTaskLineModal("- [ ] test");
  console.log("[TEST] after modal:", JSON.stringify(result), "length:", result.length);
})();

  1. In the modal that opens:
    Case A: Enter a start date and click Apply → console logs the edited line.
    Case B: Leave out the start date and click Apply → console logs the edited line without 🛫.
    Case C: Click Cancel → console shows [TEST] before modal but never logs [TEST] after modal. The promise never resolves.

Expected Behavior

According to the Tasks API documentation, editTaskLineModal() should always resolve:

  • Return the edited line if Apply is clicked.
  • Return an empty string "" if Cancel is clicked.

Current behaviour

  • Clicking "Apply" with or without start date works as expected.
  • Cancel leaves the promise unresolved. No value is returned, and the awaiting code never resumes.

Impact

  • Scripts and QuickAdd macros that rely on editTaskLineModal cannot detect someone clicking "Cancel".
  • This causes workflows to hang or terminate unexpectedly, since the promise never resolves.

Which Operating Systems are you using?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Operating System Version(s)

11

Obsidian Version

1.9.14

Tasks Plugin Version

7.22.0

Checks

  • I have tried it with all other plugins disabled and the error still occurs

Possible solution

Adjust the modal’s cancel handler so that it explicitly calls the promise resolver with "".

Metadata

Metadata

Assignees

Labels

scope: for plugin developersTools for use by plugin developers, including the Tasks APItype: bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions