Overview
Follow-up for #3462636: Preview component when selecting in left sidebar.
I modified my-hero.css to add a style at the top.
button {
box-shadow: 4px 4px hotpink;
}
(then run drush cr)
Now when I hover over the Hero component in the left hand menu, the styles are loaded in but they affect the whole page.
Proposed resolution
Wrap the preview in either ShadowDom or an iFrame (iFrame might introduce issues with the way the preview is scaled)

| Comment | File | Size | Author |
|---|---|---|---|
| #8 | ezgif-3-a0fafaab54.gif | 248.63 KB | gauravvvv |
| 2024-08-06 14.01.49.gif | 176.31 KB | jessebaker |
Issue fork experience_builder-3466303
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
wim leersWhy can we not reproduce the same there? 🤔 I am fairly certain that is possible because of the work I did a decade ago on https://drupal.org/project/responsive_preview
Comment #3
jessebaker commentedIt's certainly not impossible to do with an iFrame but there will be challenges around rendering the iFrame at the correct size (the same size as the content) and then scaling it smaller (you can't simply show a small iFrame because then any mobile width media queries will take effect and the preview will show the mobile styling). There may also be issues with the speed at which the content can render inside an iFrame, even if you use srcdoc).
Shadowdom might just be easier - but I'm less familiar with it so it may have unforeseen limitations too.
Comment #4
wim leersAhhh, gotcha! 👍 Thanks for providing that additional context 😊
Comment #5
gauravvvv commentedComment #6
utkarsh_33 commentedAssigning it to me as there is no update till now on this.
Comment #8
gauravvvv commentedTests are failing, working on them.

Here is the after MR screen recording:
Comment #9
utkarsh_33 commentedI have fixed the tests.It's up for a review.As i was also working on the same issue so i thought i could fix the tests.
Comment #10
wim leersComment #11
wim leersComment #12
wim leersComment #13
utkarsh_33 commentedComment #14
wim leersComment #16
jessebaker commented