Skip to content
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

Can't initiate render in plugin: Tabs #2941

Closed
3 of 7 tasks
xhuajin opened this issue Jul 7, 2024 · 10 comments · Fixed by #2945
Closed
3 of 7 tasks

Can't initiate render in plugin: Tabs #2941

xhuajin opened this issue Jul 7, 2024 · 10 comments · Fixed by #2945
Labels
scope: rendering of tasks How the plugin displays tasks (except CSS issues) type: bug Something isn't working type: other plugin Issues that involve another plugin, or an interaction between this plugin and another one

Comments

@xhuajin
Copy link
Contributor

xhuajin commented Jul 7, 2024

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

  • I searched previous Bug Reports didn't find any similar reports.

Expected Behavior

Expected render tasks view in plugin tabs.

image

Current behaviour

Query results component doesn't automaticly render.

image

Steps to reproduce

  1. Install the plugin 'Tasks', 'Tabs'
  2. Input a task query in tabs codeblock.

image

Which Operating Systems are you using?

  • Android
  • iPhone/iPad
  • Linux
  • macOS
  • Windows

Obsidian Version

1.6.2

Tasks Plugin Version

7.6.0

Checks

  • I have tried it with all other plugins disabled and the error still occurs

Possible solution

After testing, I found that the issue is that the query results of the tasks plugin are not rendering. Adding a this.onload(); at the end of the constructor of the QueryRenderChild class in QueryRenderer.ts allows it to render normally. (Dataview also does this. See dataview/plugin-api.ts).

image

https://github.com/blacksmithgu/obsidian-dataview/blob/15b8d527e3d5822c5ef9bfd23f528a64769d545b/src/api/plugin-api.ts#L400

Could you please add an active render step, or is there anything I can do to help?

@claremacrae
Copy link
Collaborator

claremacrae commented Jul 7, 2024

Hi, thanks for using Tasks.

There are a couple of things I don't understand about this request...

  1. What is initiative render in Can't initiative render ?
  2. 'I have tried it with all other plugins disabled and the error still occurs' is checked, but the issue seems to be dependent on having a second plugin installed...

@claremacrae claremacrae added type: other plugin Issues that involve another plugin, or an interaction between this plugin and another one scope: rendering of tasks How the plugin displays tasks (except CSS issues) labels Jul 7, 2024
@xhuajin
Copy link
Contributor Author

xhuajin commented Jul 7, 2024

Hi, thanks for your reply.

  1. Can't initialtive render means when rendering a tasks query by the MarkdownRenderer.render() provided by obsidian, for example

text = "```tasks\nnot done\n```", MarkdownRender.render(app, text, el, ...)

The query is successful, but the element generated by the query is not rendered. After I tried to add this.onload() to the QueryRenderChild constructor, the result generated by the query was rendered. So the issue was raised in search of a solution.

  1. My understanding is wrong, I understand that other plugins except these two are closed. I apologize for the confusion.

@claremacrae
Copy link
Collaborator

There is content in your screenshot in the reproduction that is not provided as text for me to copy, so for reasons explained in the following post, I am unable to investigate:

https://publish.obsidian.md/tasks/Support+and+Help/Report+a+Bug

And since this is a bug involving another plugin, please create a minimal vault that reproduces the problem, and attach it here.

Many thanks.

@claremacrae claremacrae changed the title Can't initiative render in plugin: Tabs Can't initiate render in plugin: Tabs Jul 7, 2024
@xhuajin
Copy link
Contributor Author

xhuajin commented Jul 8, 2024

Very grateful for your assistance! I create a minimal vault that reproduces the problem.

Test.zip

@claremacrae
Copy link
Collaborator

Very grateful for your assistance! I create a minimal vault that reproduces the problem.

Test.zip

Brilliant - that was a great set of examples, making the behaviour really clear.

I was able to see the problem, and work out which code location you were talking about changing....

This patch does make the Tasks query in the Tabs code block render the tasks, and all the Tasks facilities work fine.

Index: src/Renderer/QueryRenderer.ts
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/Renderer/QueryRenderer.ts b/src/Renderer/QueryRenderer.ts
--- a/src/Renderer/QueryRenderer.ts	(revision a80decedfb21c14f8fef0826ee7b0d6f55705f78)
+++ b/src/Renderer/QueryRenderer.ts	(date 1720420427772)
@@ -38,16 +38,16 @@
     public addQueryRenderChild = this._addQueryRenderChild.bind(this);
 
     private async _addQueryRenderChild(source: string, element: HTMLElement, context: MarkdownPostProcessorContext) {
-        context.addChild(
-            new QueryRenderChild({
-                app: this.app,
-                plugin: this.plugin,
-                events: this.events,
-                container: element,
-                source,
-                filePath: context.sourcePath,
-            }),
-        );
+        const queryRenderChild = new QueryRenderChild({
+            app: this.app,
+            plugin: this.plugin,
+            events: this.events,
+            container: element,
+            source,
+            filePath: context.sourcePath,
+        });
+        context.addChild(queryRenderChild);
+        queryRenderChild.load();
     }
 }

@claremacrae
Copy link
Collaborator

Awesome - thanks very much indeed @xhuajin for finding the issue and the fix!

@xhuajin
Copy link
Contributor Author

xhuajin commented Jul 9, 2024

Also thank you for the fix. Have a good day!

@claremacrae
Copy link
Collaborator

This will be included in the next Tasks release.
The time for this is unknown.

@claremacrae
Copy link
Collaborator

The fix for this is now released, in Tasks 7.6.1.

@xhuajin
Copy link
Contributor Author

xhuajin commented Jul 12, 2024

Get it. Thanks for your efforts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: rendering of tasks How the plugin displays tasks (except CSS issues) type: bug Something isn't working type: other plugin Issues that involve another plugin, or an interaction between this plugin and another one
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants