Skip to content

Commit 6663dfd

Browse files
authored
add more rules for dialog parents and children (#5945)
1 parent fa028b2 commit 6663dfd

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

pyi_hashes.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"reflex/components/radix/primitives/__init__.pyi": "01c388fe7a1f5426a16676404344edf6",
4848
"reflex/components/radix/primitives/accordion.pyi": "19484eca0ad53f538f5db04c09921738",
4949
"reflex/components/radix/primitives/base.pyi": "9ef34884fb6028dc017df5e2db639c81",
50-
"reflex/components/radix/primitives/dialog.pyi": "1bc7533791b07928ad1ade5f616b81d4",
50+
"reflex/components/radix/primitives/dialog.pyi": "9ee73362bb59619c482b6b0d07033f37",
5151
"reflex/components/radix/primitives/drawer.pyi": "921e45dfaf5b9131ef27c561c3acca2e",
5252
"reflex/components/radix/primitives/form.pyi": "78055e820703c98c3b838aa889566365",
5353
"reflex/components/radix/primitives/progress.pyi": "c917952d57ddb3e138a40c4005120d5e",

reflex/components/radix/primitives/dialog.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Interactive components provided by @radix-ui/react-dialog."""
22

3-
from typing import Any
3+
from typing import Any, ClassVar
44

55
from reflex.components.component import ComponentNamespace
66
from reflex.components.el import elements
@@ -35,6 +35,11 @@ class DialogRoot(DialogElement):
3535
# The modality of the dialog. When set to true, interaction with outside elements will be disabled and only dialog content will be visible to screen readers.
3636
modal: Var[bool]
3737

38+
_valid_children: ClassVar[list[str]] = [
39+
"DialogTrigger",
40+
"DialogPortal",
41+
]
42+
3843

3944
class DialogPortal(DialogElement):
4045
"""Portal component for Dialog."""
@@ -48,6 +53,8 @@ class DialogPortal(DialogElement):
4853
# Specify a container element to portal the content into.
4954
container: Var[Any]
5055

56+
_valid_parents: ClassVar[list[str]] = ["DialogRoot"]
57+
5158

5259
class DialogOverlay(DialogElement):
5360
"""A layer that covers the inert portion of the view when the dialog is open."""
@@ -61,6 +68,8 @@ class DialogOverlay(DialogElement):
6168
# Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries. It inherits from Dialog.Portal.
6269
force_mount: Var[bool]
6370

71+
_valid_parents: ClassVar[list[str]] = ["DialogPortal"]
72+
6473

6574
class DialogTrigger(DialogElement, RadixPrimitiveTriggerComponent):
6675
"""Trigger an action or event, to open a Dialog modal."""
@@ -73,7 +82,7 @@ class DialogTrigger(DialogElement, RadixPrimitiveTriggerComponent):
7382

7483
_memoization_mode = MemoizationMode(recursive=False)
7584

76-
_valid_parents = ["DialogRoot"]
85+
_valid_parents: ClassVar[list[str]] = ["DialogRoot"]
7786

7887

7988
class DialogContent(elements.Div, DialogElement):
@@ -103,6 +112,8 @@ class DialogContent(elements.Div, DialogElement):
103112
# Fired when the pointer interacts outside the dialog.
104113
on_interact_outside: EventHandler[no_args_event_spec]
105114

115+
_valid_parents: ClassVar[list[str]] = ["DialogPortal"]
116+
106117

107118
class DialogTitle(DialogElement):
108119
"""Title component to display inside a Dialog modal."""

0 commit comments

Comments
 (0)