Skip to content

fix: portal modal to document.body to prevent Projects section overlap#9

Open
Adichapati wants to merge 1 commit into
BetoxPrograming:mainfrom
Adichapati:fix/modal-portal-stacking-context
Open

fix: portal modal to document.body to prevent Projects section overlap#9
Adichapati wants to merge 1 commit into
BetoxPrograming:mainfrom
Adichapati:fix/modal-portal-stacking-context

Conversation

@Adichapati
Copy link
Copy Markdown

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. With z-50 on a position: fixed element at root level, the modal now correctly sits above all page content.

Changes

  • src/app/components/Background.tsx: Added createPortal import from react-dom; wrapped modal render in createPortal(..., document.body)

Verification

  • npm run build passes cleanly
  • No regressions in styling — all existing Tailwind classes preserved

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.
Copilot AI review requested due to automatic review settings May 25, 2026 05:28
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 createPortal from react-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
)}
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.

Projects section overlaps the modal

2 participants