Skip to content

Conversation

@jungpaeng
Copy link
Member

Description

Related Issue: Fixes # (issue_number)

Changes

  • Added componentKey property to overlay components
  • Added componentKey parameter to the open event
  • Changed the key value in ContentOverlayController from overlayId to componentKey
  • Added componentKey field with related JSDoc comments to the OverlayItem type

Motivation and Context

Improved component lifecycle management by separating the overlay's unique identifier (overlayId) from the React component's key value.

Previously, when the same overlayId was reused, components weren't properly remounted. Now, componentKey is always generated as a new random value, ensuring correct mount/unmount cycles for components.

How Has This Been Tested?

overlay.open(
  ({ isOpen, close, unmount }) => {
    return (
      <Modal isOpen={isOpen} onExit={unmount}>
        <div
          style={{ display: 'flex', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' }}
        >
          <p>MODAL CONTENT</p>
          <button onClick={close}>close modal</button>
        </div>
      </Modal>
    );
  },
  { overlayId: 'test' }
);

setTimeout(() => {
  overlay.unmount('test');
  overlay.open(
    ({ isOpen, close, unmount }) => {
      return (
        <Modal isOpen={isOpen} onExit={unmount}>
          <div
            style={{
              display: 'flex',
              flexDirection: 'column',
              alignItems: 'center',
              justifyContent: 'center',
            }}
          >
            <p>MODAL CONTENT</p>
            <button onClick={close}>close modal</button>
          </div>
        </Modal>
      );
    },
    { overlayId: 'test' }
  );

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have performed a self-review of my own code.
  • My code is commented, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.
  • Any dependent changes have been merged and published in downstream modules.

Further Comments

@jungpaeng jungpaeng self-assigned this May 1, 2025
@changeset-bot
Copy link

changeset-bot bot commented May 1, 2025

⚠️ No Changeset found

Latest commit: 2c79c59

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

@vercel
Copy link

vercel bot commented May 1, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
overlay-kit ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 1, 2025 7:46am

@codecov-commenter
Copy link

codecov-commenter commented May 1, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.44%. Comparing base (a98a312) to head (d9c5e4c).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #151      +/-   ##
==========================================
+ Coverage   94.32%   94.44%   +0.11%     
==========================================
  Files          12       12              
  Lines         335      342       +7     
  Branches       86       86              
==========================================
+ Hits          316      323       +7     
  Misses         18       18              
  Partials        1        1              
Components Coverage Δ
overlay-kit 94.44% <100.00%> (+0.11%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jungpaeng jungpaeng closed this May 1, 2025
@jungpaeng jungpaeng reopened this May 1, 2025
@jungpaeng jungpaeng merged commit 07f42a5 into main May 1, 2025
18 checks passed
@jungpaeng jungpaeng deleted the fix/component-key branch May 1, 2025 07:52
@github-actions github-actions bot mentioned this pull request May 1, 2025
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.

3 participants