Skip to content

How to programmatically control open/close state of MorphingDialog?#174

Description

@WesleyHuchit

Hi 馃憢

First of all, great work on motion-primitives. The MorphingDialog animations are excellent.

I have a question regarding programmatic control of the dialog open/close state.

From the current API and implementation, MorphingDialog manages its own internal state (isOpen) via context and does not expose any of the following:

  • open / onOpenChange props
  • ref or imperative handle
  • a public hook to access setIsOpen

This makes it difficult to handle common use cases such as:

  • Closing the dialog after an async action succeeds (e.g. submit / save / API call)
  • Integrating with external state managers
  • Coordinating dialog state with router navigation or mutations

Example use case
async function onSubmit() { await saveData() // how can I close MorphingDialog here? }

Question

What is the recommended way to control or close MorphingDialog programmatically?

Is it expected that consumers should:

  1. unmount the dialog?
  2. rely only on MorphingDialogClose clicks?

Or would exposing something like:

  1. open / onOpenChange
  2. or a public useMorphingDialog() hook be aligned with the intended design?

I鈥檇 love to understand the design decision here and the best practice moving forward.

Thanks in advance 馃檹

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions