Overview
As an example the SDC component experience_builder/tests/modules/xb_test_sdc/components/props-slots/props-slots.twig has a height of 100vh specified.
The preview iFrame's height is matched to the height of the content. The use of VH means that component will try and be the height of the iFrame. The combo of these two things leads to an infinite loop of the iFrame expanding to contain the component and then the component expanding to match the height of the iFrame.
Proposed resolution
There is already a half-solution in place to catch this but it's not working. ui/src/hooks/useSyncIframeHeightToContent.ts:64
- The code has a bug that checks
element instanceof HTMLElementwhich is a) unnecessary and also b) not truthy which skips the actual vh check - The check for vh will only work for inline styles.
element.style.heightdoes not return a value if the height is specified in a separate stylesheet.So as a first step, removing the
element instanceof HTMLElementfrom the if statement will get this partially working.User interface changes
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | xb-infinite-scroll.mp4 | 111.78 KB | heyyo |
Issue fork experience_builder-3518708
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 #3
jessebaker commentedThe MR !883 should fix the issue for inline
vhunits.I’m not sure what the solution for elements with
vhunits set in a separate stylesheet would look like. To access the style with JS means callinggetComputedStyle()but that always returns the height inpxregardless of what unit was specified. Perhaps some kind of rate limit on the iframe height check? Perhaps parsing stylesheets before the page is rendered somehow?Comment #4
jessebaker commentedComment #6
nagwani commentedComment #7
heyyo commentedI experienced the same bug, just by setting margin-top, or margin-block (but not margin-bottom).
Video attached.
Comment #8
larowlan@heyyo is that against 0.x? Can you share that SDC (or point me towards somewhere it lives in a repo)?
@jessebaker this was merged is 'Active' the correct status?
Comment #9
heyyo commentedYes my test was against 0.x, but after I saw another issue on the same bug, didn't test it yet.
https://www.drupal.org/project/experience_builder/issues/3534490
It's a local playground for now, still unsure to contribute.
But it's a custom theme with daisyui/tailwind, and this bug appears just by applying the tailwind class mt-{y} or my-{y}
which sets only margin-top or margin-block, nothing related to height of the container.
I didn't test outside tailwind, to see we have the same issue
Comment #10
heyyo commentedI confirm, that margin-top/margin-block issue is fixed with the other issue:
https://www.drupal.org/project/experience_builder/issues/3534490
Comment #11
lauriiiThis is getting fixed in #3534490: Cannot use `h-screen` from Tailwind with XB