Skip to content

Reserve DartPad embed height before client-side hydration - #14106

Open
kevmoo wants to merge 3 commits into
mainfrom
gsc-dartpad-height
Open

kevmoo wants to merge 3 commits into
mainfrom
gsc-dartpad-height

Conversation

@kevmoo

@kevmoo kevmoo commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Applies identical pixel height and border sizing to pre-rendered DartPad code
blocks and hydrated DartPad iframes on docs.flutter.dev.

  • Pre-hydration height parity: Renders
    <pre class="embedded-dartpad" style="height: ...px"> with matching 2px
    borders so hydrating <iframe class="embedded-dartpad"> causes zero vertical
    layout shift.
  • Fence attribute parsing: Accepts positive whole-pixel height values with
    an optional px suffix in CodeBlockProcessor and normalizes height="640"
    in nested-nav.md.

Presubmit checklist

  • If you are unwilling, or unable, to sign the CLA, even for a tiny, one-word PR, please file an issue instead of a PR.
  • If this PR is not meant to land until a future stable release, mark it as draft with an explanation.
  • This PR follows the Google Developer Documentation Style Guidelines—for example, it doesn't use i.e. or e.g., and it avoids I and we (first-person pronouns).
  • This PR uses semantic line breaks
    of 80 characters or fewer.

- Renders pre-hydration DartPad code blocks with matching pixel height
  and 2px border sizing to prevent vertical layout shift on hydration.
- Parses positive whole-pixel height attributes with optional px
  suffixes in CodeBlockProcessor and normalizes nested-nav.md.

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request refactors how DartPad embed heights are handled and styled to prevent layout shifts during hydration. It changes the height property of DartPadWrapper to a required int (representing pixels), introduces a helper _parseDartPadHeight in CodeBlockProcessor to parse and validate heights (supporting optional 'px' suffixes), and updates the SASS styles to apply the same class (.embedded-dartpad) and height to both the pre-rendered <pre> placeholder and the hydrated <iframe>. Additionally, a comprehensive test suite has been added to verify this behavior. I have no feedback to provide as the implementation is clean and correct.

@flutter-website-bot

flutter-website-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Staged preview of the updated docs.flutter.dev site (updated for commit da10087):

https://flutter-docs-prod--docs-pr14106-gsc-dartpad-height-nflpy9r0.web.app

@flutter-website-bot

flutter-website-bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

Staged preview of the updated flutter.dev site (updated for commit da10087):

https://flutter-dev-230821--www-pr14106-gsc-dartpad-height-y7reuu5s.web.app

- Mark `sites/www/test/dartpad_height_test.dart` `@TestOn('vm')` so
  browser-targeted test runs (`dart test -p chrome`) skip `jaspr/server.dart`
  instead of failing on `Platform.environment`.
- Initialize `Jaspr.initializeApp(options: defaultServerOptions)` to verify
  `@client` hydration marker height serialization, avoid poisoning isolate-wide
  `ServerOptions`, and silence `NoClientScriptAdapter` warnings.
- Cover `DartPadInjector`'s default `400px` height fallback and unquoted
  `height=520` fence attributes.
@parlough parlough self-assigned this Nov 19, 2026
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.

3 participants