I’ve tried to use dev-tool to help me find out the name of the items that I want to hide, but they’re the same name. I can’t hide one of them; I can only hide all of them.
This is what I’ve tried, but this is only making all my context menu items hidden, that not I want!
I want to find a way to hide some specific context menu items that are useless to me, for example, “Set as attachment folder” or “Open local graph” or the items from the plugins that I’ve installed.
The further question is how can I hide the buttons using the same name in the dev-tool? Because some buttons in Obsidian I’ll never use, and they’re so annoying.
I’m sorry, this is not, and I’ve already seen “this”. And your snippet doesn’t work by the way, you can’t hide “Help” or “Settings” or “Open another vault”.
What I am looking for is to hide a particular item from your right-click to a folder or a note.
Sorry about that. “Specific context menu items” gave me the impression you wanted to hide some (or all) of the icons, not the whole sidebar.
In case you ever need them again but want them visually tucked away, quite a few themes have features that hide the sidebar until you hover the left side of the window.
Ah, now I understand what you’re after. Yes, I was indeed looking at the wrong menu.
After some digging, unfortunately I cannot see any way to target these items individually with css, as they all have the same class of menu-item with no additional attributes.
Looks like a job for a plugin. I can’t recall seeing any that looked to this particular menu, but perhaps someone out there knows of one, or could look into making one. That’s above my skillset.
If you don’t get any other answers here, I’d suggest opening a plugin request that looks to remove unwanted elements from this menu. It’s possible there are others who wish for the same amount of control.
Lastly, I am able to hide the ‘Settings’, ‘Help’, and ‘Open another vault’ icons with the following. Note this will not remove the whole left sidebar, just the icons.
It doesn’t look like you’re using a theme, but perhaps some other active code is interfering with this? You could try adding an !important flag after each, like so:
I came here looking for the exact same solution; specifically to hide the “Set as attachment folder” context menu, which I have accidentally selected several times because it’s right next to the New Folder menu item.
Why does it even need to be visible when the option to save in a sub-folder has already been set? It makes sense if you have specified one folder location for attachments (because you may want to change it) but if you have selected to always put attachments in the current folder location (or into a sub-folder of the current location) then the ‘Set as attachment folder’ menu is redundant because all it does is mess up your settings if it’s accidentally clicked.
I am surprised to hear that there is not even any way to hide it using css. I was trying various things for at least an hour, and wondering why nothing worked.
In a CSS snippet you could use the nth-child or nth-of-type pseduo-class to hide the undesired menu items (for example, the third, fourth, and sixth .menu-item).
You may want to check if the .menu-item class is used elsewhere, and target more specifically (like .file-manager .context-menu .menu-item, as a made-up example) to avoid hiding other items.
If the number of items in the menu changes (due to updates or plugins), you’ll need to update the snippet.
OK, I looked at the markup and I don’t see any way to distinguish one context menu from another, so my suggestion won’t work. Whether you right-click on a file in the file manager or a heading in a note, you get the same markup.
It might be worth filing a feature request for better markup.