Skip to content

Dropdown menu native form submit#3790

Open
markocupic024 wants to merge 2 commits intoradix-ui:mainfrom
markocupic024:dropdown-menu-native-form-submit
Open

Dropdown menu native form submit#3790
markocupic024 wants to merge 2 commits intoradix-ui:mainfrom
markocupic024:dropdown-menu-native-form-submit

Conversation

@markocupic024
Copy link
Copy Markdown

Closes #3789

Description

Previously, this could be submitted with keyboard navigation:

import { DropdownMenu } from '@radix-ui/react-dropdown-menu';
 function Example() {
  return (
    <>
      <DropdownMenu.Root>
        <DropdownMenu.Trigger>Open</DropdownMenu.Trigger>
        <DropdownMenu.Content>
          <DropdownMenu.Item asChild>
            {/* Does NOT submit the form */}
            <button type="submit" form="my-form">Submit</button>
             {/* Adding onClick={() => {}} DOES submit the form */}
            {/* <button type="submit" form="my-form" onClick={() => {}}>Submit</button> */}
          </DropdownMenu.Item>
        </DropdownMenu.Content>
      </DropdownMenu.Root>
       <form id="my-form" action="/submit" method="post" />
    </>
  );
}

But using mouse to click did not work.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Jan 13, 2026

🦋 Changeset detected

Latest commit: 0c41505

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 5 packages
Name Type
@radix-ui/react-menu Patch
@radix-ui/react-context-menu Patch
@radix-ui/react-dropdown-menu Patch
@radix-ui/react-menubar Patch
radix-ui Patch

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

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.

[DropdownMenu] Native form submission via form attribute doesn't work with asChild unless child has explicit onClick handler

1 participant