[TechSpeak] Sitecore SXA: the Add Here Button Is Hidden in Experience Editor

Updated Apr 8, 2024

In this blog post, I will describe an issue we had in a project that was based on Sitecore 9.2 SXA + JSS, and explain how we solved the problem.

The Sitecore Experience Accelerator (SXA) has a great feature called Presentation, which allows you to build shared data separately (Partial Designs) and apply these Partials to a Page Design that can be used on any content page.

Sitecore SXA

It’s a really flexible approach to reusing shared components. For instance, we can create Partials for both Header and Footer sections, which are usually used on each content page.

The Problem

Let’s get back to our problem. Our client informed us that, using Experience Editor, he couldn’t add any components on content pages that used SXA Page Design. In other words, the Add Here button was hidden in a placeholder.

The screenshot below shows how Experience Editor is supposed to behave when adding a page component to any placeholder. When you click a target placeholder, the Add Here button is supposed to show up:

Add_Here_Main
Add Here All Root

In the following screenshots, you can see that the Add Here button is hidden for no reason and that subsequently components cannot be added to that placeholder:

Main_No_Label
Not Able To Add Component header

Solution

After investigating, I found out that Sitecore SXA uses the SXA[PlaceholderChromeData] cache when an SXA page is open in the Experience Editor:

SXA Placeholder Chrome Data

When this issue appeared in the Experience Editor, I implemented a custom Sitecore command to clear the SXA[PlaceholderChromeData] cache.

Below is the source code that needs to be applied to Sitecore Instance.

  1. Custom Sitecore Command:
1public class XACacheClearer : Command
2{
3public override void Execute(CommandContext context)
4{
5const string sxaCache = "SXA[PlaceholderChromeData]";
6 
7var cache = CacheManager.FindCacheByName <string>($"{sxaCache}");
8cache?.Clear();
9 
10SheerResponse.Alert("Cache cleared.");
11}
12}

Where

  • Command — abstract type Sitecore.Shell.Framework.Commands.Command (Sitecore.Kernel.dll)
  • CacheManager — type with static methods Sitecore.Caching.CacheManager (Sitecore.Kernel.dll)
  1. Sitecore config patch to apply the XACacheClearer command:
2    <sitecore>
3      <commands>
4        <command name="clearxacache" type ="[YourProject].Foundation.Caching.Commands.XACacheClearer, [YourProject].Foundation.Caching"></command>
5      </commands>
6    </sitecore>
7</configuration>

A short reminder of how to add a custom action to the Sitecore Ribbon:

Switch Sitecore Content Management context to the core database and navigate to /sitecore/content/Applications/Content Editor/Ribbons:

Sitecore Ribbons
  • Under Ribbons, create a new Chunk as per below:
Chunk
  • Then create a new Strip (e.g. under Home) and paste the reference to the Chunk you created above:
Sitecore Strip cr
  • Make sure a new Action appears in the Sitecore Ribbon (in my case in the Home tab):
Sitecore Ribbon Action

The next step is to check this action. Click the action and make sure the SXA[PlaceholderChromeData] cache is cleared:

Cache Cleared

Navigate to the [sc]/sitecore/admin/cache.aspx URL to get all the Sitecore caches.

Cache Empty

That’s all for today. I hope the Sitecore SXA team fixes this issue soon.

Happy coding, Sitecorians!

Leave a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>