Dialog: Best practices for controlling externally
#2794
Replies: 1 comment 1 reply
-
|
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.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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
openprop, I'm conditionally rendering a different dialog component depending on what type of action the user initiated. "Delete" uses anAlertDialog; "Edit" uses aDialogwith a form. This is primarily to make the TypeScript easier to manage, but in theory I can change things to instead use theopenprop.I have a few questions and concerns with this approach. I'm hoping someone here can help me?
Dialog.Triggerto aDialog.Rootwithout nesting it as a child?onClickon theDialog.Triggerwhen my external button is clicked using a Reactref?defaultOpenprop instead ofopen?defaultOpentooltip 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 theDialogcomponent. 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