Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Dialog] Close the dialog after asynchronous form submission without declaring state #2864

Open
s97712 opened this issue Apr 24, 2024 · 2 comments

Comments

@s97712
Copy link

s97712 commented Apr 24, 2024

Feature request

Overview

Please consider introducing the Dialog.Consume component, which can receive Function as Child Component and pass functions like setOpen to the sub-components.

This can make the code more concise and reduce the burden of state management.

Example:

<Dialog.Consume>
  {({setOpen})=>(
    <Button onClick={async ()=>{
      await submit()
      setOpen(false)
    }} >
      Submit
    </Button>
  )}
</Dialog.Consume>

or

<Dialog.Consume render={({setOpen})=>(
    <Button onClick={async ()=>{
      await submit()
      setOpen(false)
    }} >
      Submit
    </Button>
)}/>
@ikidoncc
Copy link

I don't think it would be worth adopting this feature, since the Radix Primitive concept is meant to be more generic. But you can create this yourself in your applications if you really feel the need.

@s97712
Copy link
Author

s97712 commented Apr 25, 2024

I don't understand how this affects its generality. Its idea is the same as Dialog.Trigger and Dialog.Close , which is to avoid declaring state, but it is more flexible and powerful than Dialog.Trigger and Dialog.Close.

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

No branches or pull requests

2 participants