-
Notifications
You must be signed in to change notification settings - Fork 12
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
Typing a new note name will save the new title when hitting space #22
Comments
I can confirm this issue. Hence i can't add space in file name currently when using the plugin. |
Same, I took a look through the code and couldn't find anything that would cause this so I suspect it is due to some behavior change with new version of Obsidian. |
Observed behaviour: When the user creates a new note, its title is "Untitled", and it is immediately highlighted.
|
+1. Too bad this hasn't been fixed since May. |
PRs are welcome. |
I'd be glad to help, but first I'd rather know if this plugin is still being mantained (cc @shichongrui) |
I no longer use it and thus don't spend time actively working on it. But it still seems to get a fair amount of use, so I'm willing to look at PRs, or transfer ownership as I've done with other plugins I created and no longer use. |
Thanks for replying @shichongrui! I understand. I'll work towards fixing this issue. If I succeed — meaning that I'm capable of keep tinkering the code — you can transfer its ownership to me if you want to 😄 |
I can confirm, when creating new note and adding a title, it saves the file after first hitting space. I have to come back to add the rest of the title. I disabled the plugin and it solved the issue |
I looked into it a bit, and it seems that the issue can also be reproduced without this plugin. When you start typing a title, and then hit use the command "Files: Reveal current file in navigation" (what is referred to as |
Thank you for digging into it, @lightheaded! |
@lightheaded - Maybe I'm misunderstanding what you tested, but that doesn't seem relevant to the actual issue here? The complaint is that hitting Yes, manually running the command may cause those things to happen too, but this still shouldn't be happening automatically just because |
Taking a quick look at the source code for the plugin, my best guess is that the I'm not familiar with Obsidian plugin development, but I wonder if that handler can be updated to do a check to see if the file title input currently has focus, and if so, don't call |
Sorry for being perhaps too brief in my description. I tried to isolate the root cause. I started commenting out code and trying to reproduce the issue to see what parts of the code were causing it. I found out that commenting out this line removes the issue. (this.app as any).commands.executeCommandById('file-explorer:reveal-active-file'); Which makes sense, as this is the line that delivers most of the value that this plugin offers. Now, this command can be executed without the use of this plugin as well. So I disabled the plugin, and tried to reproduce the issue outlined by the issue author. I used the "Files: Reveal current file in navigation", then created a new file, and as soon as I hit space, the focus jumped back to the Files sidebar (and as a result of the loss of focus, the title gets updated / file gets saved). This led me to believe that the Obsidian's internal "Files: Reveal current file in navigation" command is the one that traps focus to the Files sidebar, but in such a way that the focus is brought back to it whenever "space" is hit. Similarly how you can press a button on a website by hitting space as long as it has focus. So my conclusion is that the bug seems to be with the "Files: Reveal current file in navigation" command, and not this plugin itself. Therefore, the fix should take place by the Obsidian team, not the plugin author. There might be workarounds to reoslve the issue without waiting for Obsidian to fix the issue, as Pane Relief manages to bypass focus stealing, but I didn't have time to look into that. My initial workaround was to hold space while typing the title, but it's not possible on the mobile, so I resorted to locking focus using the Pane Relief plugin.
As far as I remember from my debugging, the file-open event is not fired by hitting
None of the code in the plugin seems to be triggered at the time the focus is stolen from the title input. The stage is set before that by calling reveal(), and subsequently Screen.Recording.2024-07-22.at.09.34.56.movSo to circumvent the issue, the focus should be "locked" somehow while the title input is focused. I didn't have time so far to dig through the docs and I'm quite unfamiliar with Obsidian's API/architecture. If anyone can point me to the right direction regarding the APIs we'd need to use, I'm happy to do that. I'm sure Pane Relief source code might help here. |
@lightheaded - I understand your findings now, thanks for the detailed follow-up. I took a look at the pane-relief source code, and it appears that the way it "locks" the focus is actually just regularly setting the focus back to the main document via This line, which I just tested out in the developer console, seems to do the trick, though I admit I haven't checked the doc of either method involved to confirm that this is an appropriate use case.
|
Any progress please? |
Hello. Can you please write here: https://forum.obsidian.md/t/the-proven-spacebar-bug/87745 |
Hello. Can you please write here: https://forum.obsidian.md/t/the-proven-spacebar-bug/87745 |
It would be nice to have this issue resolved someday. The default way of right-clicking on the note's name (in the top menu breadcrumb) at the top of a note, then selecting "Reveal file in navigation" option has been a blessing so far. |
At least for me on MacOS, when I am typing a new note name and I hit space, it saves the file name with this plugin enabled. I am not sure if it was happening before I updated (I don't think it was) but it's happening with v1.3.3 that was just released.
I can reproduce this by creating a new vault, enabling just this plugin and then trying to create a new note.
The text was updated successfully, but these errors were encountered: