pane-relief icon indicating copy to clipboard operation
pane-relief copied to clipboard

menu entries "Navigate back/forward" not working

Open depressiveRobot opened this issue 2 years ago • 15 comments

When using your plugin, the navigation buttons in the title bar work perfectly.

However, the menu entries View -> Navigate back and View -> Navigate forward do not work.

Obsidian: v0.13.19 Pane Relief: 0.0.17 OS: macOS Monterey 12.1

depressiveRobot avatar Jan 25 '22 19:01 depressiveRobot

I'm on Windows and don't really have any way to test that. But my guess is that those are tied to the browser history for Electron, rather than being Obsidian menu items per se. The mouse forward/back buttons should work correctly, as well as the Obsidian keyboard commands for going forward and back.

I'm afraid I have no clue how to go about fixing this, as I didn't realize Obsidian had OS-level menus! (You are talking about the macOS menu at the top of the screen, not a menu inside Obsidian, right?)

pjeby avatar Jan 25 '22 22:01 pjeby

I would like to help you fix that.

First, yes, I am talking about the macOS menu entries. There are also command palette commands with the same name: Navigate back and Navigate forward. According to my testing, the are doing the same as the macOS menu entries. I also have the same issues as described by the plugin, that's why I want to use it.

Is there any way I can help you by debugging Obsidian? Do you have an idea how can I get debug information what is triggered in Obsidian by the commands/menu entries?

depressiveRobot avatar Jan 26 '22 15:01 depressiveRobot

Hm. I'm on 0.13.19 and the navigate forward/back commands in Obsidian work correctly, i.e. they do the same as the buttons. Can you describe what is happening, and what you expect to happen instead? (With both the commands and the menu, and how it differs from what the buttons are doing.)

Also, how are your panes arranged, and are you using sliding panes? Which pane is active when you use the command, and what do the buttons show as the number of available forward or back pages?

pjeby avatar Jan 26 '22 20:01 pjeby

In short:

  • the buttons work as expected
  • the command palette commands work as expected
  • the macOS menu entries don't work at all (which a need, because they are mapped to mouse and trackpad for navigation)

Here is a short video which may be worth more than 1000 words: https://user-images.githubusercontent.com/6043497/151662318-61ac3e34-2a3d-4b4c-9956-16865c6cb0ce.mov

depressiveRobot avatar Jan 29 '22 13:01 depressiveRobot

Do the menu entries work without pane relief? (Try in the Help Vault, so you don't lose any history from your main.)

Also, interesting about the menu, since I didn't know Obsidian had menus on macOS. It certainly doesn't have them elsewhere. Unfortunately, I don't think there is any way for Obsidian plugins to access the menu system, because that's controlled by the main electron process, not the process where the main app runs. (It would be nice if it could - I'd love to have similar menus on Windows.) So I may not be able to override those menu options without help from the Obsidian core developers.

pjeby avatar Jan 29 '22 19:01 pjeby

Yes, the menu entries have the same behavior as the buttons and the command palette commands (without Pane Relief).

depressiveRobot avatar Jan 29 '22 22:01 depressiveRobot

Hm. This is really weird. Neither Obsidian nor Electron appear to be creating such a menu. The default Electron viewMenu is very similar, except it's reload, force reload, toggle dev tools, then the zoom stuff and toggle full screen. That is, the Electron default menu doesn't have the minimize or navigate options, and as far as I can tell, Obsidian doesn't add them.

The only thing I can think of is if you're on a different Electron version than the code I'm looking at; can you check process.versions.electron in the dev tools window?

pjeby avatar Jan 29 '22 23:01 pjeby

process.versions.electronshows: "13.6.2"

depressiveRobot avatar Jan 29 '22 23:01 depressiveRobot

Okay, so it must be something the Obsidian installer on Mac adds, but does in such a way that it bypasses the Obsidian command system and tells the internal browser API to do it. (Because Electron doesn't have any code to tweak the menu that way, and neither does the Windows installer.)

I don't think this is something I can fix on my side; it sounds like I'll need to ask Licat if they can change the Mac installer to forward the command from the main process to the renderer, or alternately have a way for Obsidian plugins to hook or modify the app menu in some fashion.

pjeby avatar Jan 30 '22 00:01 pjeby

Okay, so I've talked to Licat and he thinks that the thing that's doing this is fixed in Electron 16 and that Obsidian is going to that soon, so he wants to see if that fixes the problem before doing anything.

I also finally found the bit of Obsidian that does set up the menu like that, turns out I was looking in the completely wrong place, but it tells Electron to do the navigation, and Electron (at least as of v13) isn't forwarding those commands to the window.history object (which is what Pane Relief hooks into). In 16 that may have changed and so may work.

If it doesn't, then the Obsidian code setting the navigation menu will need to change, which I can't change because it would mean patching part of the code that starts Obsidian, long before plugins even start to run. So we'll have to revisit this once Obsidian is using Electron 16.

pjeby avatar Jan 30 '22 05:01 pjeby

Okay, so Obsidian is now on Electron 17 (as of the 0.13.31 installer), so can you check whether the problem still happens with that version? (Note that you need to download and reinstall, and your process.versions.electron should show 17.1.1.)

pjeby avatar Mar 11 '22 17:03 pjeby

Unfortunately, it still doesn't work. Sorry. The same behavior as before: the macOS menu entries don't work. Uninstalling the plugin makes the menu entries work again.

process.versions.electron shows 17.1.1

depressiveRobot avatar Mar 15 '22 08:03 depressiveRobot

Just a status update; I spoke to Licat and he said they think fixing this is "definitely possible", but did not give a time frame for what release it would be in. It definitely requires an updated Obsidian core app, which is what sets up the menu items and how they communicate with the vault window.

pjeby avatar Apr 07 '22 04:04 pjeby

The problem still exists with Obsidian 0.15.6., process.versions.electron shows 18.0.4.

depressiveRobot avatar Jul 17 '22 12:07 depressiveRobot

I've asked again for them to make the change. As far as I'm aware, it's not possible for the plugin to modify the menus as they are created by a different OS process than the one that plugins run in. But even if it is possible to change it, I don't have a Mac to implement or test it on: the Windows version of Obsidian doesn't set up any menus at all. So this relies entirely on the core devs changing the menus, or else on getting a skilled Electron+Obsidian hacker w/a Mac to come up with a way to patch the menus from the renderer process.

pjeby avatar Jul 17 '22 20:07 pjeby