chrisgurney / obsidian-note-toolbar

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

Clicking any Button Causes Obsidian to Reload #41

Closed MrComputron closed 1 month ago

MrComputron commented 1 month ago

https://github.com/chrisgurney/obsidian-note-toolbar/assets/46870771/9e5fd2fd-1e8a-45a7-a85a-49ff99da23e5

https://github.com/chrisgurney/obsidian-note-toolbar/assets/46870771/3eb99981-4e2c-4e8b-9505-261499a2769a

Selecting any button in a toolbar on mobile causes Obsidian to reload.

Steps to reproduce

  1. Be in obsidian (either live preview or preview)
  2. Click any note toolbar button

Expected behavior

Screenshots (if you think it will help) Video or a GIF would be appreciated.

Theme links and CSS snippets (if applicable): Issue occurs with all themes, however installed themes are:

Plugin links (if applicable): If you're using a specific plugin that isn't working with the toolbar, link it here. Not sure if any of these is responsible

Desktop environment:

Mobile environment (if applicable to the issue):

Additional context Thanks.

chrisgurney commented 1 month ago

@MrComputron thanks for logging the issue!

Can you provide more details on what the links in your toolbar are that you're getting this result with? Are they Commands, Files, or URIs? What exactly are they?

MrComputron commented 1 month ago

Just added a couple of screen recordings above. All the Note Toolbar buttons added are commands. I have not yet tested out links or URI with NT.

chrisgurney commented 1 month ago

@MrComputron Thanks for the recordings. Can you give an example of one of the commands you're using that's exhibiting the issue?

MrComputron commented 1 month ago

All commands have at times had this issue. Commands I've set up in toolbars include:

The major frustration with it is that it works and stops working inconsistently...sometimes it works for 5-6 button presses before it reloads, sometimes it reloads on the first, and there is no obvious pattern to when it will reload.

chrisgurney commented 1 month ago

@MrComputron Appreciate all the details so far.

Is it possible to perhaps start a new vault with just the Note Toolbar plugin and use a core plugin command, to see if it happens with that setup?

chrisgurney commented 1 month ago

@MrComputron If you're willing to try out the beta, I've just pushed an update that you can try: look for v1.5.6-beta or later. I'd be interested in whether this fixes the issue for you or not.

Technical Notes

The change was moving the preventDefault() calls earlier in the click handler, which previously were after attempting to execute the command. My theory (unproven) is that occasionally, with lots of plugins, that call might take a while to do, and without the preventDefault() being earlier was allowing the click (to #) to actually go through. (I've just read it's good practice to do the preventDefault() earlier, anyway.)

chrisgurney commented 1 month ago

@MrComputron The latest version is now available on Community Plugins with this change. Please let me know if it helps! 🤞

MrComputron commented 1 month ago

It is all working without issue now and I am very pleased about it. Thanks for the update and again for all the work you are putting into this plugin!