Skip to content

chore: add portal context with comprehensive tests and storybook demo#6821

Merged
francinelucca merged 3 commits intochore/add-portal-contextfrom
copilot/stack-pr-6815
Sep 10, 2025
Merged

chore: add portal context with comprehensive tests and storybook demo#6821
francinelucca merged 3 commits intochore/add-portal-contextfrom
copilot/stack-pr-6815

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 9, 2025

Adds PortalContext functionality to allow developers to control where Portal content is rendered, along with comprehensive tests and Storybook documentation.

Changes Made

  • PortalContext: Added React context to control portal container selection
  • Portal Component: Enhanced to use PortalContext when no containerName prop is provided
  • Comprehensive Tests: Added test suite covering all PortalContext scenarios including:
    • Default portal behavior without context
    • Custom portal rendering via PortalContext
    • Context value override with containerName prop
  • Storybook Story: Added "With Portal Context" story demonstrating practical usage with visual examples
  • Bug Fix: Removed duplicate line in Portal.tsx component

Testing & Documentation

  • ✅ Added comprehensive unit tests for PortalContext functionality
  • ✅ Added interactive Storybook story with visual examples
  • ✅ TypeScript compilation passes
  • ✅ All linting and formatting requirements met
  • ✅ Manual verification of portal rendering in different containers

The PortalContext allows developers to wrap Portal components and control their rendering location without needing to pass containerName props individually, providing a cleaner API for managing multiple portals in an application.

PortalContext Story

Closes #

Changelog

New

  • PortalContext for controlling portal container selection
  • Comprehensive test suite for PortalContext functionality
  • Storybook story demonstrating PortalContext usage patterns

Changed

  • Portal component now uses PortalContext when available
  • Enhanced portal registration and container management

Removed

  • Duplicate code line in Portal component

Rollout strategy

  • Minor release
  • Patch release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

The PortalContext functionality can be tested by viewing the "With Portal Context" story in Storybook under "Behaviors > Portal". The story demonstrates all use cases including default behavior, context-controlled rendering, and prop overrides.

Merge checklist


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI mentioned this pull request Sep 9, 2025
13 tasks
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Sep 9, 2025

⚠️ No Changeset found

Latest commit: f3ed64e

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot requested a deployment to storybook-preview-6816 September 9, 2025 23:35 Abandoned
Co-authored-by: francinelucca <40550942+francinelucca@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Sep 9, 2025

Just as a heads up, I was blocked by some firewall rules while working on your feedback. Expand below for details.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Copilot AI changed the title [WIP] chore: add Storybook story for PortalContext usage feedback chore: add portal context with comprehensive tests and storybook demo Sep 9, 2025
Copilot AI requested a review from francinelucca September 9, 2025 23:47
@github-actions github-actions bot added the integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm label Sep 10, 2025
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi, this pull request contains changes to the source code that github/github depends on. If you are GitHub staff, we recommend testing these changes with github/github using the integration workflow. Thanks!

}) => {
const {portalContainerName} = useContext(PortalContext)
const elementRef = React.useRef<HTMLDivElement | null>(null)
const {portalContainerName} = useContext(PortalContext)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@copilot re-add this line

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I attempted to re-add the line as requested, but it causes a syntax error since it creates a duplicate variable declaration: Identifier 'portalContainerName' has already been declared. The line const {portalContainerName} = useContext(PortalContext) already exists on line 73.

Could you clarify what specific line should be added at line 75? If you need the PortalContext usage in a different way, please let me know the intended implementation.

@francinelucca francinelucca marked this pull request as ready for review September 10, 2025 14:14
@francinelucca francinelucca requested a review from a team as a code owner September 10, 2025 14:14
@francinelucca francinelucca added the skip changeset This change does not need a changelog label Sep 10, 2025
@francinelucca francinelucca merged commit c19577c into chore/add-portal-context Sep 10, 2025
33 of 37 checks passed
@francinelucca francinelucca deleted the copilot/stack-pr-6815 branch September 10, 2025 14:14
@github-actions
Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
packages/react/dist/browser.esm.js 88.66 KB (+0.09% 🔺)
packages/react/dist/browser.umd.js 88.71 KB (+0.01% 🔺)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: recommended This change needs to be tested for breaking changes. See https://arc.net/l/quote/tdmpakpm skip changeset This change does not need a changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants