chore: Allow Portal's hidden SSR placeholder in the SSR test - #4908
Open
TrevorBurnham wants to merge 2 commits into
Open
chore: Allow Portal's hidden SSR placeholder in the SSR test#4908TrevorBurnham wants to merge 2 commits into
TrevorBurnham wants to merge 2 commits into
Conversation
The SSR test asserts that modal and tooltip emit no server markup at all, because Portal returns null on the server. component-toolkit#249 makes Portal render its hidden placeholder span during SSR so that the server markup matches the first client render, which would break that assertion. Assert what the test actually cares about instead: the portaled content is not in the server markup, and whatever is emitted is either nothing or the hidden placeholder. Passes both before and after that change.
NathanZlion
approved these changes
Aug 17, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4908 +/- ##
=======================================
Coverage 97.66% 97.66%
=======================================
Files 958 958
Lines 31317 31317
Branches 11566 11566
=======================================
Hits 30585 30585
Misses 686 686
Partials 46 46 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
|
CI run failures appear to be due to an issue on |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR updates a test assertion that will fail once cloudscape-design/component-toolkit#249 is merged. It should be merged first to prevent the tests in this repo from failing.
Description
Portalrenders a hidden probe span on its first render so its layout effect can readref.current.ownerDocument. That span was gated ontypeof document !== 'undefined', so the server emitted nothing while the client's first render emitted the span — a server/client branch on a DOM global, which React reports asHydration failed because the server rendered HTML didn't match the clientbefore discarding and re-rendering the subtree. The toolkit fix renders the span during SSR too, so both passes agree.Portalis the sole root of bothInternalModal(src/modal/internal.tsx:82) andTooltip(src/internal/components/tooltip/index.tsx:73), so their server markup is the Portal's output. That takes it from""to<span style="display:none"></span>, and this assertion fails:The comment also encodes the assumption the toolkit fix invalidates — the portal API not working on the server is exactly why the first render has to match, not a reason to emit nothing.
The new assertion in this PR asserts what the test actually cares about: the portaled content is not in the server markup, and whatever is emitted is either nothing or the hidden placeholder.