How can we help you today?

How to Hide the SharePoint Toolbox By Default

By default, when you edit your SharePoint page, the SharePoint Toolbox pops up automatically:


Toolbox


In some cases, the Toolbox breaks the page and requires a reload before editing. If you’ve experienced this, this article will show you how to automatically hide the Toolbox when you edit the SharePoint page:


hide Toolbox


TABLE OF CONTENTS


Prerequisites

  • You must have the latest version of ShortPoint SPFx installed on your SharePoint environment.
  • You must be a ShortPoint Designer with an active license.

Step-by-step Tutorial

Follow the steps to learn how to hide the Toolbox by default:


Step 1: Open the ShortPoint Theme Builder


NOTEBy using the ShortPoint Theme Builder, the code we will use in this article will be applied to your whole Site Collection.


Go to a SharePoint page and click the ShortPoint icon:


ShortPoint icon


Select Theme Builder:


Theme Builder


Step 2: Open Custom JavaScript

Scroll down and click Utilities:


Utilities


Open Custom JavaScript:


Custom JavaScript


Step 3: Copy code

Copy the code below:

function handleEditButtonClick(retryCount = 0) {
    const editButton = document.querySelector('button[aria-label="Edit Page"]');
    const toolBoxElement = document.querySelector('[data-automationid="panelHeader-closebutton"]');
    ++retryCount;
    if (toolBoxElement) {
      setTimeout(simulateToolBoxButtonClick, 500);
    }
    if (editButton) {
        editButton.addEventListener('click', function(e) {
            e.preventDefault();
            console.log('Edit button clicked');
            setTimeout(simulateToolBoxButtonClick, 1000);
        });
    } else if (retryCount < 5) {
        console.error('Edit button not found');
        setTimeout(() => {
          handleEditButtonClick(retryCount);
        }, 500);
    }
}

const simulateToolBoxButtonClick = () => {
    const toolBoxElement = document.querySelector('[data-automationid="panelHeader-closebutton"]');
  
    if (toolBoxElement) {
      toolBoxElement?.click();
    } else {
        setTimeout(() => {
            simulateToolBoxButtonClick();
        }, 500);
    }
  };

  handleEditButtonClick();

Step 4: Paste the code

Paste the code in the Custom JavaScript field:


Custom JavaScript


Click Apply:


Apply


Step 5: Publish

Publish to save your changes:


Publish


NOTEIf you wish to apply this solution to only the SharePoint page you’re editing, you can use the Code Design Element. Simply paste the code in the JavaScript field and disable Sandbox Mode: 


Congratulations! Now, when you edit the page, the Toolbox is automatically hidden:


hidden Toolbox


Related articles:

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.

World's best intranet sites are designed using ShortPoint

Get started today! Learn more
See all 26 topics

Start a trial

Ignite your vision. Install ShortPoint directly on your site, or play in sandbox mode. No credit card required.

Get started today

World’s best intranet sites are designed using ShortPoint

Thousands of companies using ShortPoint everyday to design, brand and build award winning intranet sites.

Get started Learn more