feat: add portalTarget prop to mount viewer overlay in a custom DOM…#216
Merged
Conversation
… element * feat: add portalTarget prop for custom portal mount location Agent-Logs-Url: https://github.com/motopods/react-zmage/sessions/d359f9e9-8370-4eff-bb9e-31623ffee11c Co-authored-by: motopods <58200641+motopods@users.noreply.github.com> * refactor: simplify portalTarget null handling per review feedback Agent-Logs-Url: https://github.com/motopods/react-zmage/sessions/d359f9e9-8370-4eff-bb9e-31623ffee11c Co-authored-by: motopods <58200641+motopods@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: motopods <58200641+motopods@users.noreply.github.com>
Owner
|
Thanks for your contribution! This PR looks good, let me try it out. |
Caldis
added a commit
that referenced
this pull request
May 18, 2026
Bump react-zmage to 1.9.0 and point all sandbox tarball checks at the 1.9.0 package. Regenerate static docs metadata and asset references so the published website reports the new version. The portalTarget feature was merged from PR #216 with synchronized public docs, playground examples, and llms-eval coverage.
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.
The viewer overlay was always mounted on
document.bodywith no way to scope it to a specific DOM subtree — a blocker for isolated containers, shadow-DOM hosts, and modal-within-modal layouts.Changes
types/global.ts—portalTarget?: HTMLElement | nulladded toInterfaceAndInteractionParams(public API surface)types/default.ts—portalTargetthreaded throughgetConfigFromPropsintoconfigPropsPortal/Portal.tsx—targetprop widened toHTMLElement | nullBrowser/Browser.tsx—portalTargetdestructured fromgetPropsWithEnv()and forwarded to<Portals target={portalTarget}>Zmage.callee.tsx— imperativeZmage.browsing()path usesportalTarget ?? document.bodyas the React tree mount parentUsage
Omitting
portalTargetpreserves the existingdocument.bodydefault.