Overview

If I use the h-screen class from Tailwind, the page continues to grow indefinitely. It is common to use this class for heros / banners / sections that should be sized according to browsers height.

Proposed resolution

User interface changes

Command icon 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

lauriii created an issue. See original summary.

jessebaker’s picture

This is technically a duplicate of #3518708: Components with height in VH can cause the preview iFrame to expand infinitely in height but as no solution for that has been put forward yet, perhaps we can put in a hard-coded Tailwind specific fix for this class name.

lauriii’s picture

Issue tags: +beta target

bnjmnm made their first commit to this issue’s fork.

bnjmnm’s picture

I have an MR that will work for h-screen and any other 100VH situation, but > 100 VH settings would still be an issue. On the plus side, this covers far more use cases than HEAD, even if some linger.

bnjmnm’s picture

Status: Active » Needs review

Found a way to handle any VH value, not just 100.

jessebaker’s picture

Assigned: Unassigned » bnjmnm
Status: Needs review » Needs work
jessebaker’s picture

It seems like this issue is now the catch all for VH related issues. I've added two other more specific issues as related but I think they will be fixed by @bnjmnm's solution in the MR which is not specific to Tailwind classes.

bnjmnm’s picture

Assigned: bnjmnm » Unassigned
Status: Needs work » Needs review
lauriii’s picture

Status: Needs review » Needs work

Tried to test this manually and ran into an error:

An unexpected error has occurred while rendering preview.

Failed to execute 'querySelector' on 'Document': 'div#block-olivero-content > div.block__content > astro-island:nth-child(1) > section.bg-white.lg:grid.lg:h-screen.lg:place-content-center' is not a valid selector.

This is the component I tested with:

const Component = ({
  text = "Hero",
}) => {
  return (
  <section className="bg-white lg:grid lg:h-screen lg:place-content-center">
    <div className="mx-auto w-screen max-w-screen-xl px-4 py-16 sm:px-6 sm:py-24 lg:px-8 lg:py-32">
      <div className="mx-auto max-w-prose text-center">
        <h1 className="text-4xl font-bold text-gray-900 sm:text-5xl">
          Understand user flow and
          <strong className="text-indigo-600"> increase </strong>
          conversions
        </h1>
  
        <p className="mt-4 text-base text-pretty text-gray-700 sm:text-lg/relaxed">
          Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eaque, nisi. Natus, provident
          accusamus impedit minima harum corporis iusto.
        </p>
  
        <div className="mt-4 flex justify-center gap-4 sm:mt-6">
          <a
            className="inline-block rounded border border-indigo-600 bg-indigo-600 px-5 py-3 font-medium text-white shadow-sm transition-colors hover:bg-indigo-700"
            href="#"
          >
            Get Started
          </a>
  
          <a
            className="inline-block rounded border border-gray-200 px-5 py-3 font-medium text-gray-700 shadow-sm transition-colors hover:bg-gray-50 hover:text-gray-900"
            href="#"
          >
            Learn More
          </a>
        </div>
      </div>
    </div>
  </section>
  );
};

export default Component;
bnjmnm’s picture

Status: Needs work » Needs review

Looks like #11 was happening due to tailwind using colons in classnames. This has been addressed and a test was modified to include it as a use case.

bnjmnm’s picture

The change in Jesse's commit looks good - it's essentially the same logic as what it replaces, but uses information that was already in the component instead of having to perform additional steps to retrieve it. It seems OK if Jesse reviews the remainder of the MR.

bnjmnm’s picture

Version: 0.x-dev » 1.x-dev

  • jessebaker committed 122bd6a4 on 1.x authored by bnjmnm
    Issue #3534490 by bnjmnm, jessebaker: Cannot use `h-screen` from...
jessebaker’s picture

Status: Needs review » Fixed
mayur-sose’s picture

StatusFileSize
new64.15 KB

Verified below scenarios :

ID Test Scenario Steps Expected Result Pass/Fail
TC1 Using h-screen on a section in XB component preview Create or edit a component/page with a section using Tailwind’s h-screen class (or set style to height: 100vh).

Open the preview in XB (so it is rendered in an iFrame).
The preview appears at the correct viewport height.

The iFrame does not expand indefinitely.

No infinite scroll/bounce.
Pass
TC2 Using 100vh inline CSS in a component in preview Edit a Twig or React component in XB.

Set an element’s style to height: 100vh.

View in preview.
The iFrame preview restrains itself to one viewport height, regardless of actual content. Pass
TC3 iFrame size observed in browser dev tools Perform TC1 or TC2.

Inspect the preview iFrame’s height in browser developer tools while refreshing or saving.

Watch for rapid growth or scrollbars.
The iFrame's height remains constant Pass
TC4 Publish or save component with h-screen then view page Publish the component/page using h-screen.

Visit the published front-end endpoint.

Observe page rendering.
The page loads with correct section height (matching viewport).

No layout issues or infinite scrolling.
Pass
TC5 Multiple nested components with h-screen Place several components each using h-screen/100vh inside a parent component.

Preview page/component in XB.

Observe iFrame.
IFrame height remains bounded.

No compounding infinite growth.

Only one viewport height is used per section/component.
Pass
TC6 Non-VH heights do not cause infinite iFrame growth Use Tailwind classes like h-96, h-full, or pixel heights.

Preview component in iFrame.
IFrame does not grow infinitely regardless of content.

Confirms bug is limited to vh unit usage.
Pass
TC7 Accessibility/UX: preview iFrame is navigable/scrollable After using h-screen, try to keyboard and mouse navigate inside iFrame.

Confirm usability.
IFrame contents are accessible; no infinite scrolling traps user.

Visible scroll area matches intended height.
Pass
TC8 No other Tailwind height utilities break the iFrame preview Use classes like min-h-screen, max-h-screen or responsive variants.

Preview/save component.
IFrame height breaks after adding min-h-screen class to the component. Please check added image for the same. Fail

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.