Skip to content

Controlled Dropdown component rendered at wrong position #47152

Closed
react-component/trigger
#447
@hotzenklotz

Description

@hotzenklotz

Reproduction link

Edit on CodeSandbox

Steps to reproduce

  • Add a antd <Dropdown> as acontrolled React component to your app. Configure the dropdown to trigger on right-click, aka "contextMenu" (trigger={["contextMenu"]}).
  • Trigger the dropdown to open as a controlled component through the open prop (e.g. open={isOpen})
  • Dropdown menu is rendered at the top left corner of the screen (0,0), partially outside of the screen

What is expected?

The dropdown menu is supposed to open at the location of the component's DOM position or parent

What is actually happening?

The Dropdown menu is rendered at the top left corner of the screen (0,0), partially outside of the screen

image
Environment Info
antd 5.13.2
React 16 & 18
System MacOS 14.0
Browser Chrome 120.0.6099.199

  • I can reliably trigger the bug by configuring the dropdown to trigger on right-click, aka "contextMenu" (trigger={["contextMenu"]}). The bug does not happen with trigger={"click"}.
  • The bug only occurs if you have never triggered the Dropdown with a right-click. It must be triggered as a controlled component through the open prop.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions