obsidian-checklist-plugin icon indicating copy to clipboard operation
obsidian-checklist-plugin copied to clipboard

TODO_VIEW_TYPE leaves should not be detached on unload

Open liamcain opened this issue 2 years ago • 1 comments

Hi, I'm currently attempting to define some best practices for plugins with custom views. It's come to my attention that there are a few common anti-patterns that plugins are following when creating custom views.

Using your plugin as an example, you are detaching all the TodoListView leaves on unload. This behavior makes sense if the user is uninstalling the plugin, but when a user is instead updating the plugin, this has some undesirable behavior. The existing view will be removed from the workspace, then a new view will be created in the default position (ignoring the custom position defined by the user). Your plugin also sets that newly create leaf as active which could also be seen as undesirable.

I'm currently trying to introduce a new API for plugins to use that can standardize how plugins create their custom views, but until that becomes available, I'm proposing that plugins adopt the best practices that I outlined here in a new sample plugin: https://github.com/liamcain/obsidian-example-custom-view/blob/main/src/main.ts.

I'm also looking for feedback if you have any suggestions or concerns. Thanks!

liamcain avatar Jan 03 '23 17:01 liamcain

The last update v2.2.13 triggered this once again.

argenos avatar Oct 02 '23 22:10 argenos