Setting folder's icon color can fail for a when there's a bookmark group with the same path
Sirs0ri opened this issue · 0 comments
Describe the bug
When you have a folder in your bookmarks, and a folder in your files with the same name, depending on your editor layout, it might become impossible to change the folder's icon's color.
To Reproduce
Steps to reproduce the behavior:
- Set up your layout as shown in the screenshot below, with the bookmarks and files visible in the sidebar at the same time, and the files below the bookmarks.
- Create a bookmark folder named "Test"
- Create a folder with the same name in the files view.
- Assign an icon to the files-folder.
- Change the icon's colour. You'll notice that the popup won't close when clicking on "Save changes", and the new color will only be applied after a full obsidian reload.
Expected behavior
The popup should close when clicking "Save", and the new colour should be applied right away.
Additional context
This bug happens, because the getIconNodeFromPath(...)
method searches for the first element matching [data-path="${path}"]
, which will return the element representing the bookmark folder. That element does not represent the folder of which the icon should be recoloured, and the rest of the ChangeColorModal
's onClick()
handler fails.
In my vault, I was able to fix the issue by adjusting the selector to .tree-item-self[data-path="${path}"]
, which will work until it becomes possible to assign icons to bookmark groups as well.