MarkdownView.previewMode.rerender(true) hides note title and properties from reading view

I seem to have encountered a bug where calling MarkdownView.previewMode.rerender(true) prevents the title and, optionally, any fields, from rendering in reading view. Here are some repro steps that work on the Sandbox Vault:

Repro

Create a “Test” note at the root of the vault with the following contents:

---
Test: 42
---

In reading mode the title and the properties disappear.

Open it in a split view, and switch it to reading mode.

Next, make sure the Dataview plugin is installed and that JavaScript queries are enabled, then create a new note and paste the following code into it:

```dataviewjs
const leaves = this.app.workspace.getLeavesOfType('markdown')
for (const leaf of leaves) {
  const view = leaf.view
  if (view.file.path === 'Test.md') {
    if (view.getMode() === 'preview') {
      view.previewMode.rerender(true)
	}
  }
}

Switch to reading view to execute the code. Note the issue is not, as far as I can tell, related to Dataview, I’m simply using it as an easy way to execute code. Originally I discovered the issue by running similar code in a plugin I’m developing.

Expected Result

The “Test” note is rerendered and appears the same as before.

Actual Result

The title and properties of the note disappear. Only the content remains.

Moved to Bug Reports from Developers & API.

no please, keep this in developers and api. If anything, it’s a problem related to the API.

will be fixed in v1.5.3

1 Like

Some time ago, I encountered the same problem.

And I also found a hacky workaround: temporarily switching to Editing view and then going back to Reading view.

1 Like

Thank you! Much appreciated.

Nice, thanks for the workaround! I think I’ll use it for the time being.