Skip to content

fix(sample): size a self-reporting same-origin fitContent demo by its reports only - #194

Merged
ChronosSF merged 2 commits into
masterfrom
fix/sample-fit-content-same-origin
Nov 12, 2026
Merged

ChronosSF merged 2 commits into
masterfrom
fix/sample-fit-content-same-origin

Conversation

@simeonoff

@simeonoff simeonoff commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

Summary

A same-origin <Sample fitContent> demo was sized two ways at once: by its own igd-sample-height messages, and by a direct measurement of its <body>. When the demo page fills the iframe, that measurement only echoes the iframe height back and cuts the sample off. Once a demo reports its size, the host now uses only the reported size and stops measuring it directly. Demos that never report are still measured as before.

Related issue

Closes #193

Related: IgniteUI/igniteui-wc-examples#1317 fixes the demo side, in IgniteUI/igniteui-wc-examples#1318.

Type of change

  • Bug fix
  • New feature or component
  • Styles / theming / tokens
  • Documentation or playground only
  • Refactor, tooling or dependency update
  • Breaking change (consumer sites must change something — say what under Consumer impact)

How to test

  • npm run test:sample-widget: two new tests cover a same-origin fitContent demo, one that reports its height and one that doesn't. The reporting test fails without this change.
  • In the docs: I packed this branch, installed it in the documentation repo and ran the Web Components docs. A proxy served the docs and the deployed staging demos from one origin, as staging does. On Palette Generation, the iframe height against the demo height over three loads:
seeds sweep scales neutrals
1.7.0 92 / 460 144 / 1011 173 / 1356 144 / 1010
this branch 460 / 460 1011 / 1011 1356 / 1356 1010 / 1010

Consumer impact

None. The docs pick it up on the next igniteui-astro-components bump.

… reports only

A same-origin fitContent demo was sized by two writers: its own
igd-sample-height messages and a direct measurement of its body. When
the demo page fills the iframe, the measurement only echoes the iframe
height, and an echo that lands after the demo's last report leaves the
iframe cut off at a different height on every load.

Once a demo reports its size, stop measuring it directly.

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.

🟡 Changes recommended

The reporting flag persists across iframe navigations, blocking height updates on a subsequent non-reporting page and leaving the iframe at the previous page’s height.

1 open issue
What changed in this PR

This PR addresses #193 by making same-origin fitContent samples use reported dimensions instead of competing direct measurements, preventing reported heights from being overwritten.

Changes:

  • Skip direct measurement once a demo reports its size.
  • Preserve direct measurement for demos that never report.
  • Add regression tests for reporting and non-reporting same-origin demos.
File Description
src/​scripts/​sample-widget.ts Track size reports and skip competing direct measurements; document the behavior.
scripts/​sample-widget.test.mjs Test reported-height preservation and direct-measurement fallback.

Review effort: Balanced

Comment thread src/scripts/sample-widget.ts Resolved
The reporting flag sat on the iframe, so after the iframe navigated from
a reporting demo to a same-origin page that does not report, the new
page was never measured and kept the previous page's height. Track the
reporting document instead.

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.

🟢 Approval recommended

No active review issues remain that require changes.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@ChronosSF
ChronosSF merged commit fca14ed into master Nov 12, 2026
8 checks passed
@ChronosSF
ChronosSF deleted the fix/sample-fit-content-same-origin branch November 12, 2026 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Component: Sample Sample component (src/components/mdx/Sample)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: fitContent samples are cut off when the demo is same-origin

4 participants