Redirect an opened note to the "topmost middle sidebar" if it is already opened, instead redirect to a new tab

I have searched this question and maybe you can say if this question is a duplicate or not.

  • This first link is mostly related to Obsidian links (e.g., backlinks) instead of simple notes/tabs.
  • I have tried the suggestion in this second link. It says I must download the “No Dupe Leaves” community plugin. I also ran Obsidian without any other plugins active and chose the “Default” theme, but it doesn’t work for me.
  • I’m a bit confused by the answer in this third link. It mentions adding a new dropdown menu. I don’t want to create a user-defined plugin to make this happen, but it is a good idea. The answer also says I must disable the “Opener” plugin, which doesn’t make sense because I have never installed this plugin.

Obsidian Notes State/Condition

  • List of Enabled Community Plugins:
    • No Dupe Leaves (to solve my problem, as mentioned earlier; I have already toggled it on and off, and nothing happens)
    • Note Refactor (to solve my problem, source: ChatGPT; I have already toggled it on and off, and nothing happens)
    • Pane Relief
    • Templater (I only use this to format dates)
  • List of Enabled CSS Snippets:
    • ChangeColorTitle.css
    • multi-row-tabs.css
    • word-wrap.css
  • My Theme: Feather

Things I Have Tried

I tried to execute a JavaScript script from Obsidian on startup:

  1. I created the “_templates” folder directly inside the Vault.
  2. I created a file named open-in-the-same-tab.js inside that “_templates” folder as a “Startup Template”. This is my JS script:

document.addEventListener('click', (event) => {
  const clickedElement = event.target.closest('.nav-file-title');
  if (clickedElement) {
    const fileName = clickedElement.innerText.trim();
    const openTabs = Array.from(document.querySelectorAll('.workspace-tab-header-inner'));
    const existingTab = openTabs.find(tab => tab.innerText.trim() === fileName);

    if (existingTab) {
      event.preventDefault();
      event.stopPropagation();
      existingTab.click();
    }
  }
});
  1. I set “_templates” as the “Script files folder location”.
  2. I did this and nothing happens.

My Problem

For example, I want to open a title tab named “How to fill a …” by clicking it on the left sidebar. However, I noticed that the title is already open, so it exists in the top tabs bar region. How can I make it so that when I click that title from the left sidebar, it automatically redirects me to the same title that appears in the top tabs bar, instead of opening in a new tab, only if it is pinned?

Wanted Behavior

Condition: All these notes are already open and exist in the top tabs bar panel.

  • Clicking an existing note in the left sidebar will redirect me to the same existing note in the top tabs bar, only if the opened note is pinned.
  • Clicking an existing note in the left sidebar WILL NOT redirect me if I haven’t pinned it yet.

Obsidian Notes Version

Latest: v1.6.7

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.