Skip to content

Commit f3ca35b

Browse files
Add comprehensive prop descriptions to context menu component
- Added descriptive comments above each prop following established patterns - Sourced descriptions from official Base UI documentation - Includes default values where applicable - Follows format from existing components like checkbox.py and popover.py Co-Authored-By: Carlos Cutillas <[email protected]>
1 parent b95bf6f commit f3ca35b

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

reflex_ui/components/base/context_menu.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,18 @@ class ContextMenuRoot(ContextMenuBaseComponent):
6464

6565
tag = "ContextMenu.Root"
6666

67+
# Whether the context menu is initially open. To render a controlled context menu, use the open prop instead. Defaults to False.
6768
default_open: Var[bool]
69+
# Whether the context menu is currently open.
6870
open: Var[bool]
71+
# Event handler called when the context menu is opened or closed.
6972
on_open_change: EventHandler[passthrough_event_spec(bool, dict)]
7073
action_ref: Var[str]
74+
# When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. Defaults to True.
7175
close_parent_on_esc: Var[bool]
76+
# Event handler called after any animations complete when the context menu is closed.
7277
on_open_change_complete: EventHandler[passthrough_event_spec(bool)]
78+
# Whether the component should ignore user interaction. Defaults to False.
7379
disabled: Var[bool]
7480

7581
@classmethod
@@ -84,6 +90,7 @@ class ContextMenuTrigger(ContextMenuBaseComponent):
8490

8591
tag = "ContextMenu.Trigger"
8692

93+
# Whether the component should ignore user interaction. Defaults to False.
8794
disabled: Var[bool]
8895
render_: Var[Component]
8996

@@ -100,8 +107,9 @@ class ContextMenuPortal(ContextMenuBaseComponent):
100107

101108
tag = "ContextMenu.Portal"
102109

110+
# A parent element to render the portal element into. Defaults to document.body.
103111
container: Var[str]
104-
# Whether to keep the portal mounted when closed. Defaults to False.
112+
# Whether to keep the portal mounted in the DOM while the popup is hidden. Defaults to False.
105113
keep_mounted: Var[bool]
106114

107115
@classmethod
@@ -132,17 +140,27 @@ class ContextMenuPositioner(ContextMenuBaseComponent):
132140

133141
tag = "ContextMenu.Positioner"
134142

143+
# Determines how to handle collisions when positioning the popup. Defaults to True.
135144
collision_avoidance: Var[bool | LiteralCollisionAvoidance]
136-
# How to align the popup relative to the trigger. Defaults to "center".
145+
# How to align the popup relative to the specified side. Defaults to "center".
137146
align: Var[LiteralAlign]
147+
# Additional offset along the alignment axis in pixels. Defaults to 0.
138148
align_offset: Var[int]
149+
# Which side of the anchor element to align the popup against. May automatically change to avoid collisions. Defaults to "bottom".
139150
side: Var[LiteralSide]
151+
# Distance between the anchor and the popup in pixels. Defaults to 4.
140152
side_offset: Var[int]
153+
# Minimum distance to maintain between the arrow and the edges of the popup. Defaults to 5.
141154
arrow_padding: Var[int]
155+
# Additional space to maintain from the edge of the collision boundary. Defaults to 5.
142156
collision_padding: Var[int]
157+
# An element or a rectangle that delimits the area that the popup is confined to. Defaults to "clipping-ancestors".
143158
collision_boundary: Var[str]
159+
# Whether to maintain the popup in the viewport after the anchor element was scrolled out of view. Defaults to False.
144160
sticky: Var[bool]
161+
# Whether the popup tracks any layout shift of its positioning anchor. Defaults to True.
145162
track_anchor: Var[bool]
163+
# Determines which CSS position property to use. Defaults to "absolute".
146164
position_method: Var[LiteralPositionMethod]
147165
render_: Var[Component]
148166

@@ -160,6 +178,7 @@ class ContextMenuPopup(ContextMenuBaseComponent):
160178

161179
tag = "ContextMenu.Popup"
162180

181+
# Determines the element to focus when the context menu is closed. By default, focus returns to the trigger.
163182
final_focus: Var[str]
164183
render_: Var[Component]
165184

@@ -191,9 +210,13 @@ class ContextMenuItem(ContextMenuBaseComponent):
191210

192211
tag = "ContextMenu.Item"
193212

213+
# Overrides the text label to use when the item is matched during keyboard text navigation.
194214
label: Var[str]
215+
# Whether to close the context menu when the item is clicked. Defaults to True.
195216
close_on_click: Var[bool]
217+
# Whether the component renders a native button element when replacing it via the render prop. Defaults to False.
196218
native_button: Var[bool]
219+
# Whether the component should ignore user interaction. Defaults to False.
197220
disabled: Var[bool]
198221
render_: Var[Component]
199222

@@ -258,8 +281,11 @@ class ContextMenuRadioGroup(ContextMenuBaseComponent):
258281
tag = "ContextMenu.RadioGroup"
259282

260283
default_value: Var[str | int]
284+
# The controlled value of the radio group.
261285
value: Var[str | int]
286+
# Event handler called when the value changes.
262287
on_value_change: EventHandler[passthrough_event_spec(str | int, dict)]
288+
# Whether the component should ignore user interaction. Defaults to False.
263289
disabled: Var[bool]
264290
render_: Var[Component]
265291

@@ -276,10 +302,14 @@ class ContextMenuRadioItem(ContextMenuBaseComponent):
276302

277303
tag = "ContextMenu.RadioItem"
278304

305+
# Overrides the text label to use when the item is matched during keyboard text navigation.
279306
label: Var[str]
280307
value: Var[str | int]
308+
# Whether to close the context menu when the item is clicked. Defaults to True.
281309
close_on_click: Var[bool]
310+
# Whether the component renders a native button element when replacing it via the render prop. Defaults to False.
282311
native_button: Var[bool]
312+
# Whether the component should ignore user interaction. Defaults to False.
283313
disabled: Var[bool]
284314
render_: Var[Component]
285315

@@ -296,6 +326,7 @@ class ContextMenuRadioItemIndicator(ContextMenuBaseComponent):
296326

297327
tag = "ContextMenu.RadioItemIndicator"
298328

329+
# Whether to keep the indicator mounted in the DOM when the radio item is not checked. Defaults to False.
299330
keep_mounted: Var[bool]
300331
render_: Var[Component]
301332

@@ -312,12 +343,18 @@ class ContextMenuCheckboxItem(ContextMenuBaseComponent):
312343

313344
tag = "ContextMenu.CheckboxItem"
314345

346+
# Overrides the text label to use when the item is matched during keyboard text navigation.
315347
label: Var[str]
316348
default_checked: Var[bool]
349+
# The controlled checked state of the checkbox item.
317350
checked: Var[bool]
351+
# Event handler called when the checked state changes.
318352
on_checked_change: EventHandler[passthrough_event_spec(bool, dict)]
353+
# Whether to close the context menu when the item is clicked. Defaults to True.
319354
close_on_click: Var[bool]
355+
# Whether the component renders a native button element when replacing it via the render prop. Defaults to False.
320356
native_button: Var[bool]
357+
# Whether the component should ignore user interaction. Defaults to False.
321358
disabled: Var[bool]
322359
render_: Var[Component]
323360

@@ -334,6 +371,7 @@ class ContextMenuCheckboxItemIndicator(ContextMenuBaseComponent):
334371

335372
tag = "ContextMenu.CheckboxItemIndicator"
336373

374+
# Whether to keep the indicator mounted in the DOM when the checkbox item is not checked. Defaults to False.
337375
keep_mounted: Var[bool]
338376
render_: Var[Component]
339377

@@ -350,16 +388,27 @@ class ContextMenuSubmenuRoot(ContextMenuBaseComponent):
350388

351389
tag = "ContextMenu.SubmenuRoot"
352390

391+
# Whether the submenu is initially open. To render a controlled submenu, use the open prop instead. Defaults to False.
353392
default_open: Var[bool]
393+
# Whether the submenu is currently open.
354394
open: Var[bool]
395+
# Event handler called when the submenu is opened or closed.
355396
on_open_change: EventHandler[passthrough_event_spec(bool, dict)]
397+
# When in a submenu, determines whether pressing the Escape key closes the entire menu, or only the current child menu. Defaults to True.
356398
close_parent_on_esc: Var[bool]
399+
# Event handler called after any animations complete when the submenu is closed.
357400
on_open_change_complete: EventHandler[passthrough_event_spec(bool)]
401+
# Whether the component should ignore user interaction. Defaults to False.
358402
disabled: Var[bool]
403+
# Whether the submenu opens when the trigger is hovered. Defaults to False.
359404
open_on_hover: Var[bool]
405+
# The delay in milliseconds before the submenu opens when hovering. Defaults to 0.
360406
delay: Var[int]
407+
# The delay in milliseconds before the submenu closes when no longer hovering. Defaults to 0.
361408
close_delay: Var[int]
409+
# Whether keyboard navigation should loop around when reaching the end of the items. Defaults to False.
362410
loop: Var[bool]
411+
# The orientation of the submenu. Defaults to "vertical".
363412
orientation: Var[LiteralMenuOrientation]
364413
render_: Var[Component]
365414

@@ -375,7 +424,9 @@ class ContextMenuSubmenuTrigger(ContextMenuBaseComponent):
375424

376425
tag = "ContextMenu.SubmenuTrigger"
377426

427+
# Overrides the text label to use when the item is matched during keyboard text navigation.
378428
label: Var[str]
429+
# Whether the component renders a native button element when replacing it via the render prop. Defaults to False.
379430
native_button: Var[bool]
380431
render_: Var[Component]
381432

0 commit comments

Comments
 (0)