New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tasks alters the DOM XPath to child tasks such that other plugins cannot get the text for those Tasks #2690
Comments
Thanks @thesamim. Here are the instructions extracted from the zip, to time for anyone passing by... InstructionsloginPlease see email sent separately. monitorPlease open developer console and filter for logs with "### " to reduce the clutter. Test Tasks
TestingScenario 1:With Tasks and DataView Enabled. Close the tasks. Expected Result: In the console log, should get the Task text for all three levels.. Scenario 2:From Community Plugins, disable Tasks. Reopen then close the tasks. Expected Result: In the console log, should get the Task text for all three levels.. Scenario 3:From Community Plugins, disable Dataview AND Tasks. Reopen then close the tasks. Expected Result: In the console log, should get the Task text for all three levels.. Scenario 4:From Community Plugins, Enable Dataview AND disable Tasks. Reopen then close the tasks. Expected Result: In the console log, should get the Task text for all three levels.. Conclusion:Tasks is changing the DOM layout, such that:
|
Thanks Clare.
|
Just to add that the "Login" instruction refers to going to the TickTickSync plugin and entering the credentials there. I did Scenario 1 and got no console output at all, and not the stated expected output. I was logged in. Is this really the minimal reproduction? Why are 4 combinations required to go through? And what has dataview got to do with it? |
Just to note that following the history back, that behaviour was introduced in 54682d4 on 28/12/2022. The previous release was 1.20.0 - so you could try downloading that and test the theory that the making of the code testable was the cause. This page links to the areas of the Tasks code that adjust the re-rendering of code: https://publish.obsidian.md/tasks-contributing/Code/How+does+Tasks+handle+status+changes One thing that it shows is that the code path is quite different depending on whether it's source, live preview or reading mode. So one way to narrow down the cause might be to test the behaviour you observed, and see if it works or does not work in any particular modes. |
Will do.
Tried Source Mode and Live Preview. Made no difference to the results. In Reading Mode: TickTickSync does not get the click event at all. Haven't dug into that yet, just rely on the periodic Sync to catch us up. But I sure would like to know the answer to that too. |
Can you think of a simple way of recording the change in the DOM? I did some manual testing recently by saving HTML like this... I was going it to make sure that some refactoring of untested code did not change the behaviour: Maybe that gives some ideas about how you could save info from the development environment, to produce diff-able files that you could attach here... |
I speculate that you may have encountered a consequence of one of the know limitations of Tasks: https://publish.obsidian.md/tasks/Support+and+Help/Known+Limitations |
(This arose from #2685) |
For my money, this would be the ideal kind of reproduction - taking Dataview and TickTickSync out of the equation - and showing what it is that Tasks breaks:
And here is a diff between the two, and look, that line there is a critical diff that prevents other plugins, in the following way... |
Apparently nothing. I was just trying to prove that Dataview, as another plugin that queries Tasks, was not affecting the Tasks behaviours.
|
In essence: All that TickTickSync is doing in these scenarios is reporting results. If you can see the console log, you can see the difference in the DOM traverses. So, enabling Tasks and disabling tasks and looking at the console log accomplishes just what you’ve described.
To be super clear: I have removed ALL processing from the checkbox handler because I had no reliable way of interacting with tasks with Tasks is enabled. ALL it is doing is reporting the DOM paths it finds.
|
OK, without any screenshots in the bug report I wasn't aware of that. Unfortunately I'm not seeing any console output, so I'm a bit stumped about how to move forward. Thank for your efforts in reporting it. Actually, if you can create two separate screenshots showing:
... would it save others from going through the reproduction steps? |
Trivia: When replying by email, it really helps if people delete the text being replied too, for readability here. I've been going through deleting all the quoted text, so the flow is easier to read in future... just thought I'd mention it. |
Just to note that I haven't been involved in any of the code that adjusts the DOM - it was all written before I took over maintaining the Tasks plugin. So if this ticket can make it clear what exactly Tasks is changing or losing from the DOM, that would affect plugin developers, it will likely also inform future ideas to address some of the other known limitations of rendering of tasks by this plugin. I am currently firmly in "I don't know what I don't know" in this area. Hence the value for information to be clear and directly visible. |
D'oh - or even the text from the console, as then the captured information information would be useful for future searches.... |
Genius! Testing: With and Without Tasks, click on the tasks. Save html render from both. Save the logs from both. Finding: So, it's not an HTML structural difference apparently. It looks like the only difference is in CSS. That may cause behavioral changes. I don't know. Attached files in the zip file:
ETA: downloaded and tried with version "1.20.0". Same behavior (ie: can't get to task content from click event). So, that chunk of code probably has nothing to do with the problem. Sorry about that. |
Good, thank you, that's really helpful to know. I am sure that the CSS would not change the behaviour you are seeing. Your screenshot in #2690 (comment) and your description of this issue seem to show the "DOME XPath" is involved... Just like seeing the raw HTML was useful, "seeing" the DOM will be useful too. So I would really appreciate it if you could see if you could find a way to save the DOM for the two scenarios - only Tasks installed, and no plugin installed. Being able to diff those in a text editor would be super useful. As well as making clear all the differences, it might point to an alternative implementation in |
My searches for how to export and save the DOM were unsuccessful, and now I'm going to be mostly "Away from Keyboard" for a couple of days. |
Hi @thesamim, have you made any progress on investigations with this? Is the ticket still needed? |
Hi @claremacrae , I have an idea on how to accomplish this, but have not had time to implement it. Yes, the ticket is still needed. |
Hi @thesamim - that’s a bit Fermat”s Last Theorem! Please could you record the idea here so the info is not lost? |
In a vault, install the sample plugin only.
Using the sample plugin, add to onClickEvent a method to extract the current DOM layout. Write it to file. In the same vault, install the Tasks plugin. Repeat. Compare the two resulting files. |
Great - thanks. |
No idea if this helps, but there was just an announcement on Discord of this plugin release, and it talks about inspecting the DOM tree and being useful for general development... https://github.com/iamrecursion/obsidian-pkvs/releases/tag/1.1.0 |
Nice!!! Will explore. Thanks! |
Pardon the long delay. At the end of the day, all I want is to be able to get the Task text and the Task status. So if there's a different way to do that, please let me know. Started with the sample plugin and did some "With Tasks Enabled" and "With Tasks Disabled" testing. Methodology:
Results:
With the Tasks Plugin enabled, looking for the closest DIV, am not able to get the Task Text. Screen Shot of differences. Also see differenceReport.html in the zip file for full compare. In the zip file:
obsidian-tasks_issues_2690.zip Here are the two relevant bits of code: Capture the whole DOM as HTML:
Log relevant information when a checkbox is clicked:
Please let me know if you need anything else. |
tl;dr Yes, if you wish to pair together for a few sessions, please email me to set up some dates. Hi @thesamim, FYI the Tasks plugin is in the fortunate position of:
The above are entirely driving where my time is going on the plugin right now, there is just virtually no other time available to work on it. Additionally, as I mentioned somewhere above, fixing this is likely to require a significant re-write of the Tasks rendering code, which predates my involvement in the plugin. This means that there is zero chance of this issue being addressed in the foreseeable future, unless anyone wishes to commit to a few weekly sessions of pairing on it with me - which would push it up the priority list for my time. I should have some time for pairing in May - so if you would like to work on this together, over a few pairing sessions to try and understand what's going on and if we can can find a workaround, please email me to set up a schedule. |
Please check that this issue hasn't been reported before.
Expected Behavior
With Tasks enabled, another plugin should be able to get the Task Text to act on it.
Current behaviour
With Tasks enabled, another plugin cannot get the Task Text to act on it.
Steps to reproduce
Detailed instructions are in the Index file in the attached vault.
TTS Test Vault.zip
Which Operating Systems are you using?
Obsidian Version
v1.5.8
Tasks Plugin Version
v6.1.0
Checks
Possible solution
In
obsidian-tasks/src/Renderer/TaskLineRenderer.ts
Line 46 in 9f18c77
The text was updated successfully, but these errors were encountered: