Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active pane loses focus when opening a file in Obsidian 0.15.3 #11

Open
Randy-Astle opened this issue Jul 3, 2022 · 9 comments
Open

Comments

@Randy-Astle
Copy link

Obsidian version: 0.15.3
Pane Relief version: 0.1.8
Automatically Reveal Active File version: 1.0.2

When both Pane Relief and Automatically Reveal Active File are installed, the Pane Relief commands to move between editor panes doesn't work correctly. If I have 3+ editor panes, end up toggling between just two panes - and it looks like the left toolbar (specifically file explorer) gets the focus in the process.

As I understand it, there have been some significant changes in Obsidian 0.15.x with how panes are handled. Perhaps your extension needs to be updated.

@pjeby
Copy link

pjeby commented Jul 3, 2022

The issue is that in 0.15 the "reveal active file" command puts focus on the explorer pane. In order to not do that, the plugin would need to save the active leaf and restore it afterwards, or else trigger the reveal using another method that does not specifically open and activate the file explorer pane.

This problem doesn't actually have anything to do with Pane Relief: you can reproduce it in the sandbox vault on 0.15.3 with this installed as the only plugin. (@Randy-Astle, you might want to edit the title to reflect this, perhaps something like "active pane loses focus when opening a file in Obsidian 0.15.3", as that is what is causing your problem, and is also a problem for the plugin in general, as it requires people hit Escape after opening every file in order to work with it).

@Randy-Astle Randy-Astle changed the title Doesn't work with Pane Relief installed after the Obsidian 15.x updates Active pane loses focus when opening a file in Obsidian 0.15.3 Jul 3, 2022
@anselmwang
Copy link
Contributor

Fix this issue with #13. I have attached the compiled plugin. Would you mind to test whether this meet your requirements?
obsidian-reveal-active-file.zip

@JimKnecht
Copy link

JimKnecht commented Jul 23, 2022

I have the same focus issue with this plug that manifests in 2 ways:

  1. when I create a new file in a folder by right click, new file I have to click in the name field to name the file, without this plugin installed I don't have to do that.

  2. plugin still highlights the file but it doesn't scroll it into view if the tree is long enough to be off screen.

Here's hoping it can be fixed as this is one of the plugin I really love since I usually have several files open at once with a big tree.

@pjeby
Copy link

pjeby commented Jul 23, 2022

For anyone who needs an immediate solution for this, the Pane Relief plugin now includes a "Focus Lock" feature that prevents sidebar panes from stealing focus from the main panes. Basically, it makes Obsidian act like it used to for this plugin and many others, but the feature can be turned on and off with the mouse (click the lock in the status bar) or keyboard if you need to temporarily make the sidebar focusable, e.g. to edit a note in the sidebar. The toggle remembers its state across restarts, so you don't have to remember to switch it on each time.

Edit: Whoops, I spoke too soon. Pane Relief's focus lock prevents the file explorer pane from becoming active, but it doesn't stop it from stealing focus, which remains a problem. Sorry for getting anyone's hopes up!

@pjeby
Copy link

pjeby commented Jul 23, 2022

Update: Pane Relief 0.2.5 now prevents the file explorer pane from stealing focus when triggered by the Reveal Active File plugin or by the keyboard command, when focus lock is on. So you can use it as a fix for this issue now.

@pjeby
Copy link

pjeby commented Jul 29, 2022

Yet another update: Pane Relief 0.2.7's focus lock now keeps the file explorer from stealing focus when you're in a secondary/popout window as well, so you don't have to choose between using the reveal-active-file plugin, and being able to use secondary windows.

@c33s
Copy link

c33s commented Oct 25, 2023

with obsidian 1.1.16 and automatically reveal active file 1.0.2 i have the problem of losing focus to the side pane (directory tree) if i work with multiple windows or split panes. is this the same issue as described in this issue or should i open a new issue? i will give pane relief a try, hopefully the lock focus setting help

edit:
just tried pane relief, still the same problem: if i open a 2nd window and try to focus it, the focus jumps back to the first window. i have to click fast and multiple times on the 2nd window to get the focus there

@hsandt
Copy link

hsandt commented Feb 16, 2024

The issue was very visible when navigating through tabs with Ctrl+PageUp/PageDown repeatedly, as it would suddenly focus the Files hierarchy and start navigating across the left side panel: Files > Search > Bookmarks instead.

I confirm that installing plugin Pane Relief and using command "Pane Relief: Cycle to previous/next tab in this window" will work by ignoring side bar focus (Obsidian 1.5.3). Make sure to remove binding Ctrl+PageUp/PageDown to native commands "Go to previous/next tab" to avoid conflicts.

EDIT: I still found a limitation for general use: despite focus being kept on active file content in appearance, Obsidian will still think that we are not in file edit mode and as a result, will not display commands for that scope when using Ctrl+P to open the command palette.

Repro:

  • navigate to previous/next tab until a file highlights in hierarchy, indicating we focused to side bar
  • in appearance, the caret still blinks on the file content...
  • don't touch anything else, just open command palette with Ctrl+P
  • check for text edit commands like Toggle bold: they don't appear

This becomes an issue when chaining other navigation commands such as plugin Navigate Cursor History's own commands: Navigate Cursor History: Go back/forward, as they will stop working after the file was highlighted.

So while installing Pane Relief fixes tab navigation, other forms of navigation won't be fixed as each plugin would require that "ignore sidebar focus" feature which demands more work from every other plugin developer. So maybe the PR in work #13 is our best bet at the moment.

It may also be fixed on Obsidian API side by providing us a variant of file-explorer:reveal-active-file which would not lose editor focus, name could be file-explorer:reveal-active-file-keep-focus or so.

@pjeby
Copy link

pjeby commented Feb 16, 2024

For the people who are using Pane Relief, please note that in order to prevent the navigation issue, you have to turn on Focus Lock. That's the little padlock icon in the status bar: if it shows unlocked, click it to lock it. Once locked, you'll be able to navigate just fine without any of the problem you're reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants