fix: portal modal to document.body to prevent Projects section overlap#9
Open
Adichapati wants to merge 1 commit into
Open
fix: portal modal to document.body to prevent Projects section overlap#9Adichapati wants to merge 1 commit into
Adichapati wants to merge 1 commit into
Conversation
The Background section and Projects section both use position: relative; z-index: 10. Since the modal was rendered inside Background's stacking context but Projects appears later in the DOM at the same z-index level, Projects painted on top of the modal when scrolling. By portaling the modal to document.body via createPortal, it now sits in the root stacking context with z-50, above all page content.
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the experience modal rendering to use a React portal so the overlay is mounted at the document body level (rather than within the current component subtree).
Changes:
- Import
createPortalfromreact-dom - Render the open state modal via
createPortal(..., document.body)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| </button> | ||
|
|
||
| {isOpen && ( | ||
| {isOpen && createPortal( |
Comment on lines
+212
to
214
| </div>, | ||
| document.body | ||
| )} |
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.
Description
Fixes #6 — modal overlapping with the Projects section when scrolled.
Problem
The Background section (
position: relative; z-index: 10) and Projects section (position: relative; z-index: 10) both create CSS stacking contexts at the same z-index level. Since the modal was rendered inside Background's DOM tree but Projects appears later in the document, Projects painted on top of the modal during scroll.Fix
Wrapped the modal in
createPortal(..., document.body)so it renders at the document root level, outside any section's stacking context. Withz-50on aposition: fixedelement at root level, the modal now correctly sits above all page content.Changes
src/app/components/Background.tsx: AddedcreatePortalimport fromreact-dom; wrapped modal render increatePortal(..., document.body)Verification
npm run buildpasses cleanly