MCPcopy Create free account
hub / github.com/DioxusLabs/dioxus-components / DropdownMenuContent

Function DropdownMenuContent

primitives/src/dropdown_menu.rs:334–361  ·  view source on GitHub ↗
(props: DropdownMenuContentProps)

Source from the content-addressed store, hash-verified

332/// - `data-state`: Indicates the current state of the dropdown menu. values are `open` or `closed`.
333#[component]
334pub fn DropdownMenuContent(props: DropdownMenuContentProps) -> Element {
335 let ctx: DropdownMenuContext = use_context();
336
337 let unique_id = use_unique_id();
338 let id = use_id_or(unique_id, props.id);
339 let render = use_animated_open(id, ctx.open);
340
341 rsx! {
342 if render() {
343 div {
344 id,
345 role: "listbox",
346 aria_labelledby: "{ctx.trigger_id}",
347 "data-state": if (ctx.open)() { "open" } else { "closed" },
348 onpointerdown: move |event| {
349 // The user is starting a click inside the dropdown menu.
350 // Prevent the blur event from occurring during pointerdown,
351 // to keep the dropdown menu open until pointerup happens,
352 // thus enabling onclick/onselect events to fire.
353 event.prevent_default();
354 event.stop_propagation();
355 },
356 ..props.attributes,
357 {props.children}
358 }
359 }
360 }
361}
362
363/// The props for the [`DropdownMenuItem`] component
364#[derive(Props, Clone, PartialEq)]

Callers

nothing calls this directly

Calls 3

use_unique_idFunction · 0.85
use_id_orFunction · 0.85
use_animated_openFunction · 0.85

Tested by

no test coverage detected