lwc icon indicating copy to clipboard operation
lwc copied to clipboard

Lightning Web Security does not work when a lwc using two namespaces is dragged into the built in "body" slot of a custom community theme

Open AllanOricil opened this issue 3 years ago • 3 comments

Description

@manuel-jasso

Lightning Web Security does not work when a component using two namespaces is dragged into a community page using the community builder. If I add the same component into the layout (custom aura theme) everything works as expected.

Steps to Reproduce

1 - Create a LWC that uses two namespaces and can be used/dragged into a community page. In my case it was the local and vlocity_cmt namespaces.

2 - Create an Aura Component theme:

<aura:component implements="forceCommunity:themeLayout">
<div class="slds-grid">
  <div class="slds-col">
      {!v.body}
  </div>
</div>
</aura:component>

3 - Create a community and assign this theme to a page 4 - drag your component into this page and verify the following error happens

image

Obs: sometimes you have to click on the "refresh" button to see this error

5 - Create another Aura Component theme, but this time add your component in it instead of using a slot:

<aura:component implements="forceCommunity:themeLayout">
<div class="slds-grid">
<div class="slds-col">
       <c-my-component></c-my-component>
   </div>
</div>
</aura:component>

6 - Assign this theme to a community page 7 - preview or open the page 8 - verify it works as expected and no exception is thrown

Expected Results

Lightning Web Security should allow lwc components to use two namespaces

Actual Results

Lightning Web Security is not working well inside communities/experience sites

Browsers Affected

N/A

Version

N/A

Possible Solution Disable this namespace validation/assertion for communities when "lightning web security" is enabled

Additional context/Screenshots N/A

AllanOricil avatar Mar 12 '22 20:03 AllanOricil

I discovered what causes the bug. If you have a theme like the following, the validation/assertion is thrown everytime you drag a drop a LWC that uses two namespaces

<aura:component implements="forceCommunity:themeLayout">
<div class="slds-grid">
   <div class="slds-col">
       {!v.body}
   </div>
</div>
</aura:component>

But if you declare a slot with different name, like "content" instead of using the built in "body", you can drag and drop a lwc that makes use of two namespaces with no problem.

<aura:component implements="forceCommunity:themeLayout">
<aura:attribute name="content" type="Aura.Component[]" required="false"></aura:attribute>
<div class="slds-grid">
   <div class="slds-col">
       {!v.content}
   </div>
</div>
</aura:component>

So the bug is on the Community Builder side that is running this "assertion"

You can share this internally with the team responsible for the Community Builder.

AllanOricil avatar Mar 12 '22 20:03 AllanOricil

Ok, I actually don't have any clues of what is actually causing this bug. I know for sure that the component works as expected. The thing that intrigues me is the fact that this "Exception" happens randomly. Now I was able to drag and drop my component with no exception:

image

AllanOricil avatar Mar 12 '22 21:03 AllanOricil

This may be a duplicate of https://github.com/salesforce/lwc/issues/2714

rwaldron avatar Mar 14 '22 15:03 rwaldron