Indented tasks not recognized by Dataview
See original GitHub issueSummary
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:
Earlier this morning, the issue did not occur on mobile (screenshot of the same document as above):
…but a couple hours later I happened to open the same document and the indented tasks are now missing:
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:
- Created 2 years ago
- Comments:31 (10 by maintainers)
Top GitHub Comments
I can confirm that this is still a problem - I tested it with these versions:
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:
2 Show all tasks
When I ask dataview to show all tasks in this folder - using this query - with backticks changed to apostrophes:
I see this output, which is what I am expecting - all 5 incomplete tasks are shown:
3 Show incomplete tasks
When I filter for only incomplete tasks - using this query, by adding
!completed
to theWHERE
- with backticks changed to apostrophes:I see this output, which misses out the incomplete sub-tasks
B 1
andB 2
- only the first 3 incomplete tasks are shown:4 Observations
Note that the only difference between the working and incomplete dataview task lists is the addition of
and !completed
to theWHERE
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:So it seems to me that:
B 1
andB 2
because they are included in the output of section 2[ ]
string, i.e. are not tasks, so that they cannot be complete.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.