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

Function use_select_root

primitives/src/select/components/select.rs:123–163  ·  view source on GitHub ↗

Sets up the shared signals, focus, and context that both [`Select`] and [`SelectMulti`] need. Returns the `open` signal for the root ` `.

(
    values: Memo<Vec<RcPartialEqValue>>,
    set_value: Callback<RcPartialEqValue>,
    selection_mode: SelectionMode,
    disabled: ReadSignal<bool>,
    roving_loop: ReadSignal<bool>,
    open: Co

Source from the content-addressed store, hash-verified

121/// Sets up the shared signals, focus, and context that both [`Select`] and
122/// [`SelectMulti`] need. Returns the `open` signal for the root `<div>`.
123fn use_select_root(
124 values: Memo<Vec<RcPartialEqValue>>,
125 set_value: Callback<RcPartialEqValue>,
126 selection_mode: SelectionMode,
127 disabled: ReadSignal<bool>,
128 roving_loop: ReadSignal<bool>,
129 open: Controlled<bool>,
130 typeahead_timeout: ReadSignal<Duration>,
131) -> Memo<bool> {
132 let selectable = use_selectable_root(
133 values,
134 set_value,
135 selection_mode,
136 disabled,
137 roving_loop,
138 open,
139 );
140 let mut typeahead_buffer = use_signal(String::new);
141 let adaptive_keyboard = use_signal(super::super::text_search::AdaptiveKeyboard::new);
142 let mut typeahead_clear_task: Signal<Option<Task>> = use_signal(|| None);
143 let open = selectable.open;
144
145 // Clear the typeahead buffer when the select is closed
146 use_effect(move || {
147 if !open() {
148 if let Some(task) = typeahead_clear_task.write().take() {
149 task.cancel();
150 }
151 typeahead_buffer.take();
152 }
153 });
154 use_context_provider(|| SelectContext {
155 selectable,
156 adaptive_keyboard,
157 typeahead_buffer,
158 typeahead_clear_task,
159 typeahead_timeout,
160 });
161
162 open
163}
164
165/// # Select
166///

Callers 2

SelectFunction · 0.85
SelectMultiFunction · 0.85

Calls 1

use_selectable_rootFunction · 0.85

Tested by

no test coverage detected