From 347981201c077f2883e549db6f8a3f170e74fc1c Mon Sep 17 00:00:00 2001 From: Aaron Fenyes Date: Fri, 2 May 2025 14:51:51 -0700 Subject: [PATCH] Use `select` for click selection in outline This gets rid of duplicated code. --- app-proto/src/outline.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/app-proto/src/outline.rs b/app-proto/src/outline.rs index 2893b6d..97d6ac2 100644 --- a/app-proto/src/outline.rs +++ b/app-proto/src/outline.rs @@ -208,19 +208,9 @@ fn ElementOutlineItem(key: ElementKey, element: Rc) -> View { div( class="element", on:click={ + let state_clone = state.clone(); move |event: MouseEvent| { - if event.shift_key() { - state.selection.update(|sel| { - if !sel.remove(&key) { - sel.insert(key); - } - }); - } else { - state.selection.update(|sel| { - sel.clear(); - sel.insert(key); - }); - } + state_clone.select(key, event.shift_key()); event.stop_propagation(); event.prevent_default(); }