question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Indented tasks not recognized by Dataview

See original GitHub issue

Summary When tasks of the - [ ] taskname variety are indented, Dataview does not display them in queries.

- [ ] Task         //Dataview sees this
	- [ ] Task //Dataview does not see this

This reproduces reliably on my Mac, but not on the mobile app (iOS). Edit: the incorrect behavior now reproduces on Obsidian for iOS as well.

To Reproduce

Create a content document:

#dataviewtest

- Notes
- [ ] Task A (root level)
- [ ] Task B (root level)
- More notes
	- [ ] Task C
- Still more notes
- [ ] Task D

Create a Dataview query:

dv.taskList(dv.pages("#dataviewtest").file
  .tasks
  .where(t => !t.completed), true)

Expected result: Dataview render shows task A, B, C, and D

Actual result: Dataview render shows tasks A, B, and D

Screenshots Issue occurring on desktop: Dataview bug on desktop

Earlier this morning, the issue did not occur on mobile (screenshot of the same document as above): IMG_4D3378269398-1

…but a couple hours later I happened to open the same document and the indented tasks are now missing: IMG_0352

Desktop (please complete the following information):

  • OS: macOS 11.5.2
  • Obsidian Version 0.12.12
  • Dataview Version 0.4.5

Smartphone (please complete the following information):

  • Device: iPhone XS
  • OS: 14.7.1
  • Obsidian Version 1.0.4
  • Dataview Version 0.4.4 and 0.4.5 (tested on both versions)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:31 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
claremacraecommented, Nov 7, 2021

I can confirm that this is still a problem - I tested it with these versions:

  • dataview 0.4.17
  • dataview 0.4.20

The crucial part of reproducing the problem is adding a filter on whether the task is complete or not.

1 Markdown source

My markdown source is this, and this is in a folder where these are the only tasks - 5 incomplete tasks:

- [ ] A
    - [ ] A 1
    - [ ] B 1
- B
    - [ ] B 1
    - [ ] B 2

2 Show all tasks

When I ask dataview to show all tasks in this folder - using this query - with backticks changed to apostrophes:

'''dataview
TASK
FROM ""
WHERE file.folder = this.file.folder
SORT file.name
'''

I see this output, which is what I am expecting - all 5 incomplete tasks are shown:

image

3 Show incomplete tasks

When I filter for only incomplete tasks - using this query, by adding !completed to the WHERE - with backticks changed to apostrophes:

'''dataview
TASK
FROM ""
WHERE file.folder = this.file.folder and !completed
SORT file.name
'''

I see this output, which misses out the incomplete sub-tasks B 1 and B 2 - only the first 3 incomplete tasks are shown:

image

4 Observations

Note that the only difference between the working and incomplete dataview task lists is the addition of and !completed to the WHERE clause.

In this example, I restricted results to the local folder - but this is unrelated to the bug. Most of my dataview uses look like this - where !completed is the only filter - again with backticks converted to apostrophes:

'''dataview  
TASK  
FROM ""
WHERE !completed  
SORT file.name ASC  
'''

So it seems to me that:

  • dataview is able to find the indented tasks B 1 and B 2 because they are included in the output of section 2
  • so I strongly suspect the problem must be something to do with the filtering treating parents of indented tasks as “completed” if they do not have any [ ] string, i.e. are not tasks, so that they cannot be complete.
1reaction
blacksmithgucommented, Sep 27, 2021

How blocks underneath the task should render is a matter of preference, so the best option here is probably going to be to add a recursive where statement which lets you filter out undesired sub-nodes. I’ve added it to the next release backlog.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found