Skip to content

fix(docs): use onClick instead of onSelect on DropdownMenu.Item#467

Merged
mattrothenberg merged 5 commits intomainfrom
fix/dropdown-onclick-not-onselect
May 1, 2026
Merged

fix(docs): use onClick instead of onSelect on DropdownMenu.Item#467
mattrothenberg merged 5 commits intomainfrom
fix/dropdown-onclick-not-onselect

Conversation

@mattrothenberg
Copy link
Copy Markdown
Collaborator

Summary

  • Fix incorrect onSelectonClick on DropdownMenu.Item in CloudflareLogoDemo.tsx. DropdownMenu.Item does not have an onSelect prop — the only explicitly typed click handler from Base UI's MenuItem is onClick. onSelect only appeared to work because it's a native DOM event (GlobalEventHandlers.onselect) that React passes through to the underlying <div>.
  • Add DropdownOnClickDemo to the canonical Dropdown demos showing the correct onClick pattern, so AI agents and developers have a clear reference.
  • Fix registry codegen demo lookup to fall back to PascalCase directory name when the component export name differs from the demo file name (e.g. DropdownMenu vs Dropdown). This was silently dropping all 6 Dropdown demos from the AI registry.

Details

The CloudflareLogoDemo used onSelect on 4 DropdownMenu.Item instances. Since that demo feeds into the registry codegen pipeline, the bad pattern propagated into component-registry.md and component-registry.json — the files AI agents consume for API guidance.

The registry codegen also had a name mismatch bug: demo metadata keys are derived from filenames (DropdownDemo.tsx"Dropdown") but the registry looks up by component export name ("DropdownMenu"). The fallback to toPascalCase(config.dirName) fixes this for all affected components.

  • Reviews
    • bonk has reviewed the change
    • automated review not possible because: involves codegen pipeline behavior and demo correctness verification
  • Tests
    • Additional testing not necessary because: verified by running codegen:registry --no-cache and confirming DropdownMenu examples went from 0 → 6, all onSelect on dropdown items removed from registry output

DropdownMenu.Item does not have an onSelect prop — the only explicitly
typed click handler from Base UI's MenuItem is onClick. onSelect only
appeared to work because it's a native DOM event that React passes
through to the underlying div.

The CloudflareLogo demo used onSelect on 4 dropdown items, which
propagated into component-registry.md and component-registry.json —
the files AI agents consume for API guidance.

Changes:
- Fix onSelect → onClick in CloudflareLogoDemo
- Add DropdownOnClickDemo showing the correct onClick pattern
- Fix registry codegen to fall back to dir-name-based demo lookup
  when component export name differs from demo file name
  (e.g. DropdownMenu vs Dropdown), restoring 6 missing examples
@mattrothenberg
Copy link
Copy Markdown
Collaborator Author

/bonk

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

PR #467 Summary

Title: fix(docs): use onClick instead of onSelect on DropdownMenu.Item

What Changed

This PR fixes three interconnected issues with the DropdownMenu component documentation and registry:

1. Fixed incorrect prop usage (CloudflareLogoDemo.tsx)

  • Changed onSelectonClick on 4 DropdownMenu.Item instances
  • onSelect is not a valid prop on DropdownMenu.Item; it only appeared to work because it's a native DOM event that React passes through to the underlying <div>
  • The correct handler from Base UI's MenuItem is onClick

2. Added canonical demo example (DropdownDemo.tsx)

  • New DropdownOnClickDemo() showing the correct onClick pattern with JSDoc explaining usage
  • This serves as a reference for AI agents and developers

3. Fixed registry codegen lookup bug (component-registry/index.ts)

  • Demo metadata keys come from filenames (DropdownDemo.tsx"Dropdown")
  • Registry was looking up by component export name ("DropdownMenu") causing a mismatch
  • Added fallback to toPascalCase(config.dirName) when component name lookup fails
  • Impact: Restored 6 missing Dropdown demos to the AI registry (went from 0 → 6 examples)

Files Changed

  • .changeset/fix-dropdown-onclick.md - Changeset entry
  • packages/kumo-docs-astro/src/components/demos/CloudflareLogoDemo.tsx - Fixed prop usage
  • packages/kumo-docs-astro/src/components/demos/DropdownDemo.tsx - Added new demo
  • packages/kumo/scripts/component-registry/index.ts - Fixed lookup logic

Verification

The fix was verified by running codegen:registry --no-cache and confirming:

  • All onSelect references on dropdown items removed from registry output
  • DropdownMenu examples increased from 0 to 6

github run

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 1, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@467

commit: 8e7f13d

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Docs Preview

View docs preview

Commit: 710ddd1

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 1, 2026

Visual Regression Report — 5 changed, 33 unchanged

5 screenshot(s) with visual changes:

Button / Loading State

5 px (0%) changed

Before After Diff
Before After Diff

Dialog (Open)

0 px (0%) changed

Before After Diff
Before After Diff

Select / Select Without Label

105 px (0.1%) changed

Before After Diff
Before After Diff

Select / Select With Field

635 px (0.54%) changed

Before After Diff
Before After Diff

Select (Open)

538 px (0%) changed

Before After Diff
Before After Diff
33 screenshot(s) unchanged
  • Button / Basic
  • Button / Variant: Primary
  • Button / Variant: Secondary
  • Button / Variant: Ghost
  • Button / Variant: Destructive
  • Button / Variant: Outline
  • Button / Variant: Secondary Destructive
  • Button / Sizes
  • Button / With Icon
  • Button / Icon Only
  • Button / Disabled State
  • Button / Title
  • Button / Link as Button
  • Dialog / Dialog With Actions
  • Dialog / Dialog Basic
  • Dialog / Dialog Alert
  • Dialog / Dialog Confirmation
  • Dialog / Dialog With Select
  • Dialog / Dialog With Combobox
  • Dialog / Dialog With Dropdown
  • Select / Select Basic
  • Select / Select Sizes
  • Select / Select Placeholder
  • Select / Select With Tooltip
  • Select / Select Custom Rendering
  • Select / Select Loading
  • Select / Select Multiple
  • Select / Select Complex
  • Select / Select Disabled Options
  • Select / Select Disabled Items
  • Select / Select Grouped
  • Select / Select Grouped With Disabled
  • Select / Select Long List

Generated by Kumo Visual Regression

@mattrothenberg
Copy link
Copy Markdown
Collaborator Author

/bonk can you approve the PR too?

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

UnknownError: ProviderInitError

github run

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

@mattrothenberg Bonk workflow failed. Check the logs for details.

View workflow run · To retry, trigger Bonk again.

…PONENT_PROPS

The sub-component props extraction regex can't handle React.forwardRef
with inline intersection types, which is how all DropdownMenu
sub-components are defined. Add manual prop definitions for Item,
LinkItem, Content, SubTrigger, CheckboxItem, RadioGroup, RadioItem,
and Label — verified against Base UI type definitions.
@mattrothenberg
Copy link
Copy Markdown
Collaborator Author

/bonk approve please

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

LGTM! This PR addresses three important issues:

  1. Corrects invalid prop usage - Changing to on is the right fix since is not an explicitly typed prop on the Base UI MenuItem component.

  2. Adds canonical demo - The new provides a clear reference pattern for developers and AI agents.

  3. Fixes registry codegen bug - The fallback to properly handles the name mismatch between demo filenames and component export names, restoring 6 Dropdown demos to the AI registry.

The changeset is included, and the verification steps confirm the fix works as expected.

Copy link
Copy Markdown
Contributor

@ask-bonk ask-bonk Bot left a comment

Choose a reason for hiding this comment

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

LGTM! This PR addresses three important issues:

  1. Corrects invalid prop usage - Changing onSelect to onClick on DropdownMenu.Item is the right fix since onSelect is not an explicitly typed prop on the Base UI MenuItem component.

  2. Adds canonical demo - The new DropdownOnClickDemo provides a clear reference pattern for developers and AI agents.

  3. Fixes registry codegen bug - The fallback to toPascalCase(config.dirName) properly handles the name mismatch between demo filenames and component export names, restoring 6 Dropdown demos to the AI registry.

The changeset is included, and the verification steps confirm the fix works as expected.

@ask-bonk
Copy link
Copy Markdown
Contributor

ask-bonk Bot commented May 1, 2026

Approved PR #467

The PR has been approved. Here's a summary of what was reviewed:

Aspect Status
Prop fix (onSelectonClick) ✅ Correct - onSelect was never a valid prop on DropdownMenu.Item
New demo example ✅ Good - Provides canonical reference pattern
Registry codegen fix ✅ Critical - Restores 6 missing Dropdown demos to AI registry
Changeset included ✅ Yes
Visual regression ✅ Minor noise on unrelated components (flaky)

github run

@mattrothenberg mattrothenberg merged commit 40491c2 into main May 1, 2026
16 checks passed
@mattrothenberg mattrothenberg deleted the fix/dropdown-onclick-not-onselect branch May 1, 2026 16:12
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.

1 participant