Workspace#getActiveViewOfType does not return MarkdownView docked in sidebar

Steps to reproduce

  1. Dock a MarkdownView to the sidebar
  2. Use getActiveViewOfType(MarkdownView) to try and access the view in the sidebar or something similar like editorCallback which uses the same function internally

Expected result

This method (and the parameter of editorCallback) should be the focused markdown view in the sidebar

Actual result

The method returns the main view in the center of obsidian or nothing if no file is open. This causes commands to trigger on the wrong editor or not at all.
All of these methods do not lead to the wanted result.

console.log(this.app.workspace.getLeaf());               
console.log(this.app.workspace.getMostRecentLeaf());               
console.log(this.app.workspace.getActiveFile()); 
console.log(this.app.workspace.getActiveViewOfType(MarkdownView)); 

Environment

  • Operating system: Windows 10
  • Debug info:
SYSTEM INFO:
	Obsidian version: v0.14.6
	Installer version: v0.12.15
	Operating system: Windows 10 Pro
	Login status: not logged in
	Insider build toggle: off
	Live preview: on
	Legacy editor: off
	Base theme: dark
	Community theme: none
	Snippets enabled: 0
	Safe mode: off
	Plugins installed: 2
	Plugins enabled: 2
		1: Admonition
		2: Completr
1 Like

Related to: https://forum.obsidian.md/t/hotkeys-commands-should-apply-to-sidebar-notes-when-they-are-focused/2740