Open psigurdsson opened 3 months ago
Thank you very much for finding and reporting the problem.
Having a list of reproduction steps is also very valuable, and much appreciated.
(For future reference, if you ever report another bug in this project, you can save yourself a lot of time by assuming knowledge of basic use of Obsidian, like in this example.)
I can reproduce the problem, and will write up what I've found.
I also note that dataview doesn't recognise the folder containing a query in a canvas file:
```dataview
TASK
WHERE file.folder = this.file.folder
```
The relevant code is the context.sourcePath
value in line 48 here:
When the Tasks query block is in an ordinary Markdown file, the sourcePath is supplied:
When the Tasks query block is in a card inside a Canvas file, the sourcePath is empty:
I have asked for help on Obsidian Discord.
I will have to wait and see if the Obsidian team offers a workaround. Currently Obsidian is just not giving plugins the file path of the canvas, so there's nothing I can see to do to fix this.
Possible solution
I don't know how to fix this but there is a workaround, which is to add the note which already contains the query to the canvas:
- Right-click, an empty area in the canvas and click "Add note from vault"
- Select the note that was created in step 6, above. This will now show a canvas card with the list of tasks.
@psigurdsson You can do that a lot more easily than the Right-click option...
A simpler reproduction is:
test folder
test task
, in that folder:
Tasks: Create or edit task
Apply
test canvas
```tasks
ignore global query
filter by function task.file.folder.includes(query.file.folder)
explain
```
Actual result:
Expected result (when the same query is used in a Markdown file:
Clare, thanks for the super-quick responses and for the tips, especially on how I can report bugs more efficiently in the future. I'm happy that my bug-report helped develop the tasks plugin, which I'm a great fan of. I'm right now experimenting with creating dashboards for the various aspects of my life, including tasks that I've registered in notes inside folders which represent my areas of focus and that's where this came from. I should be able to use the workaround but there are also other ways to create dashboards than canvas and I might explore those also.
I've renamed this to make it clear that the problem is specifically querying using the folder that the query is in, rather than any old folder...
Please check that this issue hasn't been reported before.
Expected Behavior
Expected is that the following query will work when placed inside a canvas card, since it works inside a normal markdown note:
Current behaviour
Instead of showing the task contained inside the note in the subfolder, the canvas card containing this query shows the following error message:
Steps to reproduce
From @claremacrae: there is also a shorter reproduction in https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2971#issuecomment-2238535676...
Full description of the steps to reproduce:
The note should now show the task contained inside the note in the subfolder and it does.
I expected this card now to show the task contained inside the note in the subfolder, but it didn't.
Which Operating Systems are you using?
Obsidian Version
1.6.7
Tasks Plugin Version
7.6.1
Checks
Possible solution
I don't know how to fix this but there is a workaround, which is to add the note which already contains the query to the canvas:
Note from @claremacrae: there is a slightly simpler workaround in https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2971#issuecomment-2238520505...
This workaround does not adequately achieve what I want. I want to copy the canvas into many different folders, which already exist, and utilize the same tasks query dynamically. If the functionality would work as expected, I would not need to change anything in the copies in the canvas whereas in the workaround I will have to recreate many of the cards for each copy of the canvas.