obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.39k stars 225 forks source link

Edit Modal ignores edits to cancelled date #3089

Open ilandikov opened 3 days ago

ilandikov commented 3 days ago

Please check that this issue hasn't been reported before.

Expected Behavior

In Edit Modal setting status to cancelled and setting canceled date to any non today's date and clicking Apply button should save the task with the input cancelled date.

Example:

today is 2024-09-01 I set status to cancelled, the cancelled date is 2024-09-01, I set the cancelled date to any other date -> the task is saved with 2024-09-01 as cancelled date

Current behaviour

In Edit Modal setting status to cancelled and canceled date to any non today's date and clicking Apply button saves the task with today's cancelled date.

Example:

today is 2024-09-01 I set status to cancelled, the cancelled date is 2024-09-01, I set the cancelled date to 2022-02-02 -> the task is saved with 2022-02-02 as cancelled date

Steps to reproduce

  1. Open Edit Task modal on an existing task - [ ] #task todo (Global filter is set to #task)
  2. Set status to Cancelled (THIS IS THE IMPORTANT STEP, IF OMITTED, EVERYTHING WORKS FINE)
  3. Set cancelled date to any date than today's date
  4. Click Apply

Which Operating Systems are you using?

Obsidian Version

1.7.1

Tasks Plugin Version

7.10.0

Checks

The cancelled date is enabled in the settings.

Possible solution

No response

claremacrae commented 3 days ago

I don't fully understand.

Does it matter whether the Cancelled date is enabled or disabled in settings?

Does the problem occur in 7.9.0?

I wonder whether this is related to either of these:

ilandikov commented 3 days ago

I was unclear. There can be a relationship, but this is a different bug/behaviour.

I tried to clarify by adding examples in the description. Let me know if it is still unclear.

The cancelled date is enabled in the settings.

claremacrae commented 3 days ago

Thanks.

This is odd:

image

I asked about 7.9.0 in case I broke the code with the addition of the (disabled) date-picker button...

ilandikov commented 3 days ago

Fixed, thanks.

I will try 7.9.0 and keep you posted.

claremacrae commented 2 days ago

Edit Modal ignores cancel date

It does edit it under some circumstances.

claremacrae commented 2 days ago

... such as if I edit a task that is cancelled, and change the Cancelled date, the edit is preserved.

ilandikov commented 2 days ago

It does edit it under some circumstances.

Right, I found that the thing that exposes the bug is a status change from non-cancelled to cancelled.

claremacrae commented 2 days ago

That would be good to include in the Steps to Reproduce, ideally by giving a markdown line to edit, to avoid ambiguity when testing.

ilandikov commented 2 days ago

Done

claremacrae commented 2 days ago

Steps to reproduce

  1. Open Edit Task modal
  2. Set status to Cancelled (THIS IS THE IMPORTANT STEP, IF OMITTED, EVERYTHING WORKS FINE)
  3. Set cancelled date to any date than today's date
  4. Click Apply

I cannot reproduce the problem with following these steps, because Apply is disabled due to the empty description.

I generally request that users provide a Markdown line in a code-block that can be copied-and-pasted in to a markdown file, so we can copy that line, and know that we are always consistently starting the reproduction from the exact same point.

ilandikov commented 1 day ago

My bad, added additional info

claremacrae commented 1 day ago

Perfect. Thanks.

claremacrae commented 12 hours ago

This is the code that enables manual edits to the Done date to be preserved by the Edit Task modal, if the user edits the Done date after changing the status:

https://github.com/obsidian-tasks-group/obsidian-tasks/blob/787f8e0aea264f119acb365100d4115e8ff8ff9e/src/ui/EditableTask.ts#L243-L248

Indeed, the workaround for the bug is to set the required Cancelled date in the modal's Done date field.

So the fix is going to be something like: