obsidian-tasks-group / obsidian-tasks

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

CSS styling for past and future scheduled dates not applied if date inferred from the file name #1947

Open claremacrae opened 1 year ago

claremacrae commented 1 year ago

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

Expected Behavior

GIVEN a vault configured to infer task scheduled dates from dates in file names WHEN I set up custom styling for schedule dates THEN I would like tasks with inferred scheduled dates to be styled the same as tasks with matching actual scheduled dates

Current behaviour

Since any scheduled dates inferred from file names are not displayed, such tasks are not styled either.

Steps to reproduce

  1. Add and enabled this CSS snippet:
/* DATED IN FUTURE - for actionable tasks */
/* Future tasks - show description in grey, with grey background */

.task-list-item[data-task-status-type="TODO"][data-task-due^="future-"] span,
.task-list-item[data-task-status-type="TODO"][data-task-start^="future-"] span,
.task-list-item[data-task-status-type="TODO"][data-task-scheduled^="future-"] span,
.task-list-item[data-task-status-type="IN_PROGRESS"][data-task-due^="future-"] span,
.task-list-item[data-task-status-type="IN_PROGRESS"][data-task-start^="future-"] span,
.task-list-item[data-task-status-type="IN_PROGRESS"][data-task-scheduled^="future-"] span {
    color: var(--text-faint);
    background: var(--color-base-30);
    border-radius: 6px;
    padding: 1px 1px;
}

This will grey/gray out all future scheduled tasks.

  1. Create a file called 2023-05-15 auto-scheduled.md
  2. Paste in this content
---
creation date: 2023-05-12 17:12
tags: 
aliases: []
---

# 2023-05-15 auto-scheduled

## Tasks

- [ ] Lorem ipsum dolor sit amet, consectetur adipiscing elit. ⏳ 2023-05-16
- [ ]   Nam suscipit magna ut velit varius, ut convallis orci porta.
- [ ]   Suspendisse tempus nisl ut neque consectetur ullamcorper. ⏳ 2023-05-16
- [ ]   Proin sit amet enim posuere, tincidunt ligula nec, placerat massa.
- [ ]   Praesent elementum orci sit amet semper faucibus. ⏳ 2023-05-17
- [ ]   Vivamus fringilla lectus nec lorem dignissim pharetra.
- [ ]   Phasellus et lorem ac enim gravida posuere vel id nulla. ⏳2023-05-15
- [ ]   Maecenas auctor ligula bibendum tempus tempor.
- [ ]   Maecenas vel sem dignissim, tincidunt dui eu, aliquet purus. ⏳ 2023-05-18
- [ ]   Nullam sit amet nibh aliquet libero faucibus faucibus.
- [ ]   In vel quam fermentum, pellentesque leo vel, rhoncus quam.

## Search

```tasks
not done
filename includes 2023-05-15 auto-scheduled
group by happens
```
  1. View the file in Reading mode

Actual result received:

Tasks whose scheduled date came from the filename are not greyed/grayed out

image

Expected result:

That all the tasks are displayed in grey/grey - both the task lines, and the results block.

Which Operating Systems are you using?

Obsidian Version

1.3.0

Tasks Plugin Version

3.6.0

Checks

Possible solution

No response

claremacrae commented 1 year ago

@mvdkwast As the person who kindly wrote the inferred scheduled date code, I wanted to you let you see this in advance...

Basically, I'm proposing to change the behaviour so that inferred scheduled dates are rendered:

So basically changes like this:

            case 'scheduledDate':
-               if (!task.scheduledDate || task.scheduledDateIsInferred) return '';
+               if (!task.scheduledDate) return '';
                return layout.options.shortMode
                    ? ' ' + scheduledDateSymbol
                    : ` ${scheduledDateSymbol} ${task.scheduledDate.format(TaskRegularExpressions.dateFormat)}`;