feat(overlay): let the embedder name the overlay element - #2429
Conversation
The element's id is what anything outside this module finds the overlay by — a test, a screenshot tool, an integration that hides it. It was a constant, so a package adopting this overlay in place of its own would rename that id for every one of its users at once. webpack-dev-server is about to be that package, and its overlay has been `webpack-dev-server-client-overlay` for years. With `overlay.id` it keeps it, and what would have been a breaking change is a swap nobody outside has to notice. Read when the element is built and not after: the overlay is one element shared by every copy of this module on a page, so the first copy to open it names it. Two copies asking for different ids is a misconfiguration rather than a case worth supporting, and the comment says so. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
🦋 Changeset detectedLatest commit: 891faff The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 3 remain after this review. WalkthroughThe overlay options now accept an optional ID. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to The configurable overlay ID is applied to both the host and card, and the public types expose the option. No current-head issue remains that would prevent merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The default overlay ID remains unchanged, and the new option only names DOM elements; it does not change the iframe’s origin or grant privileges. Conflicting IDs across copies can make the name change after the overlay is recreated, but that configuration is explicitly unsupported. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: a2c0d293-41db-42fc-8334-780f3d152a65
📒 Files selected for processing (4)
.changeset/overlay-id-option.mdclient-src/index.jsclient-src/overlay.jstest/e2e/overlay.test.js
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2429 +/- ##
==========================================
- Coverage 96.02% 95.98% -0.05%
==========================================
Files 18 18
Lines 2015 2017 +2
==========================================
+ Hits 1935 1936 +1
- Misses 80 81 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The declarations were not regenerated after `id` was added, so it was missing from `configureOverlay`'s options and from `OverlayOptions` — a TypeScript embedder could not pass the option the change exists for. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
Summary
The overlay's element id was a constant. That id is what anything outside the module finds the overlay by — a test, a screenshot tool, an integration that hides it — so a package adopting this overlay in place of its own would rename that id for all of its users at once.
webpack-dev-server is about to be that package (webpack/webpack-dev-server#5750), and its overlay has been
webpack-dev-server-client-overlayfor years. Withoverlay.idit keeps it, and what would have been a breaking change becomes a swap nobody outside has to notice.or programmatically, for a package embedding the overlay module directly:
The card follows as
<id>-card. The default is unchanged.One deliberate limitation, stated at the code rather than left to be discovered: the id is read when the element is built and not after. The overlay is a single element shared by every copy of this module on a page — that is what the shared window state is for — so the first copy to open it names it. Two copies asking for different ids is a misconfiguration, not a case worth supporting.
What kind of change does this PR introduce?
feature
Did you add tests for your changes?
Yes, one end-to-end case: a copy configured with its own id produces a host and card under that id, and nothing is left under the default — a package embedding this one would otherwise ship two ids and have its users querying the wrong one. Teeth-checked: ignoring the option fails it.
Verified: end-to-end 111/111, lint and both typechecks clean.
test/logging.test.jsfails 74/74 on a cleanmaintoo, unrelated to this.Does this PR introduce a breaking change?
No. The option is new and the default id is what it always was.
If relevant, what needs to be documented once your changes are merged or what have you already documented?
overlay.idbelongs in the client options documentation alongsidepaginate,styles,ansiColorsandopenEditorEndpoint. Not included here.Use of AI
AI-assisted (Claude Code). Used to find that the hardcoded id was what made the webpack-dev-server overlay swap breaking, implement the option, and verify it by reverting the option's effect and confirming the test fails.
🤖 Generated with Claude Code
https://claude.ai/code/session_01UjuMAuk9o6UazjHzcAQCTA
Generated by Claude Code
Summary by CodeRabbit
overlay.idsetting to customize the overlay element’s ID. The overlay card uses the configured ID with a-cardsuffix. If omitted, the existing default ID remains unchanged.