Skip to content

Better support for controlled DialogTrigger #1039

Closed
@dkario

Description

@dkario

🙋 Feature Request

DialogTrigger can currently be used with controlled state using isOpen/onOpenChange. This is helpful when the dialog is opened by something other than a pressable child component that the DialogTrigger can wrap, like a failed XHR request fired elsewhere on the page, or a UI component that the DialogTrigger doesn't have access to. In this case, the DialogTrigger only needs the single Dialog child, but omitting a second pressable child throws the error "DialogTrigger must have exactly 2 children".

🤔 Expected Behavior

DialogTrigger should support controlled state without requiring a pressable child component.

😯 Current Behavior

DialogTrigger needs a pressable second child component in order to render, even if it's hidden or never used.

💁 Possible Solution

For now, I'm rendering a decoy button: <Button UNSAFE_className={classWithDisplayNone}></Button>, but this isn't ideal.

🔦 Context

My team needs to implement many controlled dialogs that open based on logic that lives outside the DialogTrigger, like an async validation XHR call from another component.

💻 Examples

DM me to see a demo.

🧢 Your Company/Team

Adobe/AEP

🎁 Tracking Ticket (optional)

DM me for JIRA link.

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