Skip to content

Commit 78a06ae

Browse files
committed
refactor: ! Add logging in render() to show whether we are visible and connected
1 parent 56c6459 commit 78a06ae

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/Renderer/QueryRenderer.ts

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,27 @@ class QueryRenderChild extends MarkdownRenderChild {
219219
}
220220

221221
private async render({ tasks, state }: { tasks: Task[]; state: State }) {
222-
const content = createAndAppendElement('div', this.containerEl);
223-
await this.queryResultsRenderer.render(state, tasks, content, {
224-
allTasks: this.plugin.getTasks(),
225-
allMarkdownFiles: this.app.vault.getMarkdownFiles(),
226-
backlinksClickHandler: createBacklinksClickHandler(this.app),
227-
backlinksMousedownHandler: createBacklinksMousedownHandler(this.app),
228-
editTaskPencilClickHandler: createEditTaskPencilClickHandler(this.app),
229-
});
222+
requestAnimationFrame(async () => {
223+
// We have to wrap the rendering inside requestAnimationFrame() to ensure
224+
// that we get correct values for isConnected and isShown.
225+
// (setTimeout(, 0) seemed to work too...)
226+
const isConnected = this.containerEl.isConnected;
227+
const isShown = this.containerEl.isShown();
228+
this.queryResultsRenderer.query.warn(
229+
`[render] QueryRenderChild.render() AFTER FRAME state:${state}; isConnected:${isConnected}; isShown:${isShown};`,
230+
);
230231

231-
this.containerEl.firstChild?.replaceWith(content);
232+
const content = createAndAppendElement('div', this.containerEl);
233+
await this.queryResultsRenderer.render(state, tasks, content, {
234+
allTasks: this.plugin.getTasks(),
235+
allMarkdownFiles: this.app.vault.getMarkdownFiles(),
236+
backlinksClickHandler: createBacklinksClickHandler(this.app),
237+
backlinksMousedownHandler: createBacklinksMousedownHandler(this.app),
238+
editTaskPencilClickHandler: createEditTaskPencilClickHandler(this.app),
239+
});
240+
241+
this.containerEl.firstChild?.replaceWith(content);
242+
});
232243
}
233244
}
234245

0 commit comments

Comments
 (0)