Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple Off-Platform LWC's on one page #4326

Open
ReichPhilipp opened this issue Jun 25, 2024 · 9 comments
Open

Multiple Off-Platform LWC's on one page #4326

ReichPhilipp opened this issue Jun 25, 2024 · 9 comments
Labels

Comments

@ReichPhilipp
Copy link

ReichPhilipp commented Jun 25, 2024

Hey team,

I have been working on the problem that I want to remove a LWC from the DOM and then add another LWC.
This is causing me some problems with the syntheticShadowDom. In the screenshot you can see that the previous component is used when searching for the parentNode.

Screenshot 2024-06-25 at 14 18 18

Idea is to:
load LWC1 -> Do something -> Unload LWC1 -> load LWC2 -> Do Something -> Unload LWC2 -> ...

Projectsetup:

i try to integrate the Off-Platform LWC's in an angular application. which works fine for single LWC.

Remove the LWC from DOM doesnt work. Looks like that the synthetic shadowdom is still there. How can i remove a LWC from a page?

I am quite desperate and have no further ideas

Thanks

Kind regards
Philipp

image

@nolanlawson
Copy link
Collaborator

Hi @ReichPhilipp, thanks for reaching out. A few suggestions:

  1. Could you create a minimal repro of your issue using https://playground.lwc.dev ? You can add import '@lwc/synthetic-shadow' to the top of src/main.js to add synthetic shadow to the page.
  2. If this is something specific to the Lightning Platform (Lightning Web Security, etc.) then I would recommend opening a Salesforce Stack Exchange question or a Salesforce case. In this repo, we can only resolve issues with the LWC open-source JavaScript framework.

Based on the description, it is not clear to me what the issue is, but I am suspecting that it may be related to Angular and the usage of Zone.js based on the stacktrace.

@ReichPhilipp
Copy link
Author

Thanks a lot for the answer. ❤️

i already added the @lwc/synthetic-shadow. it is part of the ./src/index.js.

i also had the feeling/idea regarding zone.js. i created a minimal version of all. That's what i tested:

  • downloaded the newest build-repo from our SalesForce instance
  • built the ExampleApp
  • copied the app-***.js into a different folger
  • duplicated the example app and renames everything to typeSecondExample...
  • built the second example app
  • used both app in the index.html
  • same issue

from my point of view it's a minimal implementation for off-platform LWC's . :)

image

that's my package.json for the minimal project
image

@nolanlawson
Copy link
Collaborator

Are you loading two copies of LWC on the same page? The error is thrown here:

if (isUndefined(record)) {
throw new TypeError();
}

...and I'm not sure how this is possible otherwise.

Can you share your minimal repro?

@ReichPhilipp
Copy link
Author

ReichPhilipp commented Jun 27, 2024

Mini Repo

i created a minimal version of the LWC-Build-Repo.

Hopefully it helps...

i will delete this repo in the future or will explain a workaround/solution there. depends ;)

@nolanlawson
Copy link
Collaborator

@ReichPhilipp I'm sorry, but I don't understand the repro steps. Could you please provide a repro and the set of Bash commands required to get the working repro up and running? Or else use something like stackblitz.com ?

@ReichPhilipp
Copy link
Author

I updated the description..

Thank you for your commitment

@nolanlawson
Copy link
Collaborator

I'm sorry, I'm still completely lost reading the directions. If this is an OmniScript-specific issue, then I would recommend opening a Salesforce case.

@nolanlawson
Copy link
Collaborator

BTW if you are willing to migrate to native shadow DOM then that may also resolve your issue.

@ReichPhilipp
Copy link
Author

we created a case today.

i tried it to migrate to the native shadow DOM. same issue 😅
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants