Dialog
: Best practices for controlling externally
#2794
Replies: 1 comment
-
I decided to change the architecture to accommodate the intended use of having the Also, for what it's worth, I used a state machine to enforce the idea of only one dialog being active at a time, to still give the parent control over the children Closing this. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a data table with a reasonably large number of rows. Each row has a column of actions (buttons) that can be performed on that row, like "Edit", "Delete". These actions open Dialog (or AlertDialog) components.
Rather than rendering each button as a
<Dialog.Root />
with a<Dialog.Trigger />
, I have one Dialog rendered in the data table, and each rows' action buttons control the opening and closing, and provide the necessary data.A row's action button changes state in the data table, and this state controls whether the Dialog is open or closed.
Rather than using the
open
prop, I'm conditionally rendering a different dialog component depending on what type of action the user initiated. "Delete" uses anAlertDialog
; "Edit" uses aDialog
with a form. This is primarily to make the TypeScript easier to manage, but in theory I can change things to instead use theopen
prop.I have a few questions and concerns with this approach. I'm hoping someone here can help me?
Dialog.Trigger
to aDialog.Root
without nesting it as a child?onClick
on theDialog.Trigger
when my external button is clicked using a Reactref
?defaultOpen
prop instead ofopen
?defaultOpen
tooltip in docs say "The open state of the dialog when it is initially rendered. Use when you do not need to control its open state." This sounds like what I would use when conditionally rendering theDialog
component. But I do "need to control its open state". I'm a bit confused.Any help, thoughts, or resources are appreciated.
I searched through the already existing discussions and didn't see anything discussing what I'm looking for.
Beta Was this translation helpful? Give feedback.
All reactions