chrisgurney / obsidian-note-toolbar

Plugin for Obsidian providing a flexible way to create context-aware toolbars for your notes.
https://github.com/chrisgurney/obsidian-note-toolbar/wiki
Apache License 2.0
283 stars 7 forks source link

[Bug Report] NTB + Notes in Split View: impact on Workspaces and Obsidian Start Up #94

Open FelipeRearden opened 3 months ago

FelipeRearden commented 3 months ago

Hello @chrisgurney !!!!!!

Description of the bug

I think I found a bug :)

ℹ️ Notes are in split view ℹ️ Both notes has NTB enable ℹ️ NTB is Top (fixed)

This issue happens in 2 scenarios: 🅰️ On Obsidian Startup 🅱️ When switching from Workspace A to Workspace B

Let me explain in details…

The issue is that NTB is not been exposed/calculated/showed in the NOT FOCUSED note in the screen.

This only happens on Obsidian Startup and switching workspaces.

📽️ I reproduced the issue in a test vault with 0% CSS (below)

https://github.com/chrisgurney/obsidian-note-toolbar/assets/85180696/66055353-ad19-4376-8ab1-215bc8f24ce6

When we focus on the broken Note, NTB is calculated correctly.

Steps to reproduce

  1. Setup a NTB with Top:fixed
  2. Create a Workspace with split notes where both has a NTB;
  3. Create a second Worksapce with split notes where both has a NTB;
  4. Switch between these two workspaces;
  5. See the NTB is hidden in the unfocused note
  6. Quit Obsidian
  7. Start Obsidian
  8. See the NTB is hidden in the unfocused note

Expected behavior

Screenshots (if you think it will help)

Above

Theme links and CSS snippets (if applicable): No CSS was used in this test

Plugin links (if applicable):

Mobile environment (if applicable to the issue):

Additional context

I don't know if can do something to avoid this 🙏

Let me know if you need more information or tests.

I wish you a fantastic day ☀️

chrisgurney commented 3 months ago

@FelipeRearden Thanks for this one! I was able to duplicate the problem.

This one will take some investigation to work out, as it touches the fundamental way I'm using to detect what file is open to render the toolbar.

FelipeRearden commented 3 months ago

Thank you very much @chrisgurney for the reply!

This one will take some investigation to work out, as it touches the fundamental way I'm using to detect what file is open to render the toolbar.

I hope you find a solution, I am gonna reflect on this to see if I found some idea to share 🙏

ℹ️ What I can say from my templater scripts is that is possible to get all notes open in the screen instead of just the active note

ℹ️ It is possible to apply a commands/rules when obsidian starts

chrisgurney commented 2 months ago

@FelipeRearden Can you please share how you do this in your Templater script?

What I can say from my templater scripts is that is possible to get all notes open in the screen instead of just the active note

FelipeRearden commented 2 months ago

@FelipeRearden Can you please share how you do this in your Templater script?

Sure @chrisgurney !!!

const thisLeaf = app.workspace.activeLeaf;
let thisFile = thisLeaf.view.file;
let leafNextLeft = app.workspace.getAdjacentLeafInDirection(thisLeaf, "left");
let leafNextRight = app.workspace.getAdjacentLeafInDirection(thisLeaf, "right");
var list = [];
this.app.workspace.iterateRootLeaves((pin) => {
    list.push(`"` + pin.view.file.basename + `"`);
})

All open files in the workspace, even pinned notes and notes that are in the sidebars

Based on Hotkeys for Files code plugin,

this.app.workspace.revealLeaf(leaf);
if (leaf.view instanceof MarkdownView) {
leaf.view.editor.focus();
}

Will focus on the open notes instead of replace the active note. I dont know how to use this in my templater snippets, but might be useful for you 🙏

https://github.com/Vinzent03/obsidian-hotkeys-for-specific-files/commit/0541bcbb3d39dbc91b2dc20dff52b45b7e5ce934

chrisgurney commented 2 months ago

Thank you @FelipeRearden!