Forum Discussion
MutationObserver to modify the SharePoint UI
Has anyone used the MutationObserver to modify the SharePoint UI? I want to remove the "Move To" and "Copy To" from the context menu (Right Click and ellipse). Is this stable and reliable? SharePoint's UI is complex and could change without notice.
Yes, we can remove these buttons via settings but they also remove other functionalities that we need.
3 Replies
aymiee You can hide Copy to and Move to options from top command bar using SharePoint JSON formatting: Command bar customization syntax reference
However, you will not be able to remove specific these options from context menu using SharePoint out of the box functionalities.
You have to create SPFx extension (Application customizer) to inject custom CSS for hiding this. However, such DOM manipulation & CSS customization are not recommended by Microsoft and some of your customization may break if Microsoft changes HTML element id/classes in new release updates.
Similar thread: Hide copy link option in context menu
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- aymieeBrass ContributorThank you!, I was able to remove all options from the top menu using the Format View. The context menu is the next step and I understand that it's not recommended but we have to turn off the ability to move to and copy to, unfortunately.
aymiee Then try using SPFx application customizer and custom CSS/JS for hiding it as mentioned in my above response.
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.