Skip to content

fix(Container): stop nested Container inheriting layout custom properties#1067

Merged
DreaminDani merged 4 commits into
mainfrom
fix/container-custom-prop-inheritance
Jun 8, 2026
Merged

fix(Container): stop nested Container inheriting layout custom properties#1067
DreaminDani merged 4 commits into
mainfrom
fix/container-custom-prop-inheritance

Conversation

@DreaminDani

@DreaminDani DreaminDani commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Problem

After the Container CSS Modules migration (#1059), nested <Container>s started inheriting layout props they never set. In control-plane this manifested as alert-banner-container stretching to fill the entire viewport, with cascading spacing breakage across the page.

image

Root cause

The migrated Container forwards optional layout props (fillHeight, grow, shrink, minHeight, maxHeight, overflow) to the DOM as CSS custom properties, emitted inline only when the prop is set. CSS custom properties inherit by default, so a descendant Container that omits those props inherits its ancestor's values:

  • A layout root with fillHeight sets --container-height: 100%, which cascades into every nested Container → height: 100% everywhere.
  • Same for --container-grow (children flex-grow), --container-overflow, etc.

The styled-components version scoped each component's styles, so nothing leaked.

Fix

Reset these custom properties to the guaranteed-invalid initial value on the base .container rule (a declaration on the element wins over inheritance), and add var() fallbacks matching the styled-components defaults.

CleanShot 2026-06-05 at 15 53 47@2x

Verification

Reproduced in a real browser against the storybook build:

flex-grow height (parent 200px) overflow
Before fix 1 (inherited) 198px (fills parent) hidden (inherited)
After fix 0 34px (hugs content) visible
  • New NestedInheritance story + computed-style regression test (tests/display/container.spec.ts).
  • All 30 existing Container visual-regression snapshots pass unchanged.

🤖 Generated with Claude Code


Note

Medium Risk
Touches a widely used layout primitive’s flex/height/overflow behavior; fix is targeted but nested layouts in consumers could change visibly where the bug had masked correct sizing.

Overview
Fixes a post–CSS Modules regression where nested Container components inherited optional layout custom properties (fillHeight, grow, shrink, minHeight, maxHeight, overflow) from ancestors, causing children to stretch or pick up flex/overflow they never set.

Container.module.css resets those six variables to initial on .container and adds var() fallbacks (auto, visible, 0 1 auto, etc.) so each instance keeps styled-components–equivalent defaults when props are omitted.

Tests & docs: Adds NestedInheritance Storybook story and a Playwright computed-style test (not pixel snapshots). Updates the CSS Modules migration skill with the reset pattern, checklist item, and pitfall note. Patch changeset and version bump to v0.6.1-rc1.

Reviewed by Cursor Bugbot for commit e10c28c. Bugbot is set up for automated code reviews on this repo. Configure here.

…ties

The CSS Modules migration forwards optional layout props (fillHeight, grow,
shrink, minHeight, maxHeight, overflow) to the DOM as CSS custom properties,
emitted inline only when the prop is set. Custom properties inherit by
default, so a nested Container that omits those props inherited its
ancestor's values — e.g. a layout root with `fillHeight` forced
`height: 100%` onto every descendant Container (observed as the control-plane
alert banner stretching to fill the viewport, with knock-on spacing breakage
throughout the page).

Reset these custom properties to `initial` on the base `.container` rule so a
declaration on the element wins over inheritance, and add `var()` fallbacks
matching the styled-components defaults. Verified in a browser: with the bug
a child Container inherited flex-grow:1/height:198px/overflow:hidden; after
the fix it hugs its content (flex-grow:0, height:34px, overflow:visible).

Adds a NestedInheritance story and a computed-style regression test; all 30
existing Container visual snapshots are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jun 5, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e10c28c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clickhouse/click-ui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a regression introduced by the Container CSS Modules migration where nested <Container> instances unintentionally inherited layout-affecting CSS custom properties from ancestors, leading to incorrect stretching/flex behavior.

Changes:

  • Reset inherited --container-* layout custom properties on the base .container rule and add var() fallbacks to preserve styled-components-era defaults when props are unset.
  • Add a Storybook regression story and a Playwright computed-style test to ensure nested Containers don’t inherit parent fillHeight/grow/overflow.
  • Add a patch changeset (and update the package version in package.json).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/components/Container/Container.module.css Resets layout-related custom properties to prevent inheritance and adds defaults via var() fallbacks.
src/components/Container/Container.stories.tsx Adds NestedInheritance story to reproduce/guard against the regression.
tests/display/container.spec.ts Adds computed-style assertions to prevent regression without relying on screenshots.
.changeset/fix-container-custom-prop-inheritance.md Records a patch-level change for the fix.
package.json Updates package version (currently formatted in a way that may break release automation).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/components/Container/Container.module.css Outdated
Comment thread package.json
DreaminDani and others added 2 commits June 5, 2026 16:00
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ules migrations

The CSS Modules migration skill covered emitting layout props as inline CSS
custom properties (and memoizing them) but not that custom properties inherit
by default. Conditionally-emitted ones therefore leak into nested instances of
the same component — the Container regression (#1059, fixed #1067) where a
parent with `fillHeight` stretched every descendant Container to full height.

Add the reset-to-`initial`-with-fallback rule to the .module.css guidance, a
matching pitfall entry, and a checklist gate, and note that visual-regression
snapshots miss this (it only shows when a component nests inside itself), so a
nested-instance computed-style test is required.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@workflow-authentication-public

Copy link
Copy Markdown
Contributor

Storybook Preview Deployed

✅ Preview URL: https://click-5ky9vr42e-clickhouse.vercel.app

Built from commit: fc0fc3f52a2f680e718baa8e771cf381f8121609

@DreaminDani DreaminDani enabled auto-merge (squash) June 5, 2026 22:19
Comment thread package.json
Comment thread src/components/Container/Container.module.css
@DreaminDani DreaminDani merged commit f6d6658 into main Jun 8, 2026
10 checks passed
@DreaminDani DreaminDani deleted the fix/container-custom-prop-inheritance branch June 8, 2026 10:15
@ariser

ariser commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

oh. Auto merge.

Comment thread tests/display/container.spec.ts
@DreaminDani

Copy link
Copy Markdown
Contributor Author

Sorry about the auto-merge, y'all. @ariser and @hoorayimhelping i'll submit a quick follow-up PR to address your feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants