Repository navigation
Fix ReusedInstanceError in Dropdown::Menu::Item divider rendering - #4172
Merged
Merged
Conversation
When rendering a divider item, the component was rendered twice—once for the divider branch and once for the content branch—because the divider branch was missing an early return. This produced a ViewComponent::ReusedInstanceError under view_component >= 4.x, which enforces single-use component instances. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
🦋 Changeset detectedLatest commit: a2e1e76 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 |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a ViewComponent::ReusedInstanceError triggered when rendering dropdown menu dividers by ensuring the divider branch returns early, preventing the same component instance from being rendered twice.
Changes:
- Add an early
returnwhendivider?is true so divider items render exactly once. - Preserve existing behavior for non-divider items by continuing to render with the content block.
Show a summary per file
| File | Description |
|---|---|
app/components/primer/alpha/dropdown/menu.rb |
Adds an early return in Dropdown::Menu::Item#call to avoid double-rendering component instances for dividers. |
Review details
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Files reviewed: 1/1 changed files
- Comments generated: 0
- Review effort level: Lite
Fixes the ReusedInstanceError occurring during the rendering of the divider in Dropdown::Menu::Item.
liuliu-dev
approved these changes
Aug 24, 2026
Merged
This branch was previously deployed
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.
Summary
Fixes three test failures surfaced by ViewComponent/view_component#2691 (which enforces single-use component instances via
ViewComponent::ReusedInstanceError):Primer::Alpha::Dropdown::MenuTest#test_renders_dividersPrimer::Alpha::Dropdown::MenuTest#test_renders_as_listPrimerAlphaDropdownTest#test_renders_dropdown_with_dividerRoot cause
In
Primer::Alpha::Dropdown::Menu::Item#call, the divider branch was missing an earlyreturn, so a singlePrimer::BaseComponentinstance was rendered twice — first as the divider, then again with a content block:This has always been latently wrong (the second
renderwas invoked even for dividers), but was harmless until view_component started rejecting reused instances.Fix
Add
returnto the divider branch so the divider is rendered exactly once and the content branch is skipped.