From 1a260f6240f817c66f00dd72106c1364f692e2ac Mon Sep 17 00:00:00 2001 From: Tienson Qin Date: Wed, 8 Nov 2023 20:48:09 +0800 Subject: [PATCH] enhance: show more/less only in the section that's selected --- src/main/frontend/components/cmdk.cljs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/frontend/components/cmdk.cljs b/src/main/frontend/components/cmdk.cljs index 04796cacd..050616c83 100644 --- a/src/main/frontend/components/cmdk.cljs +++ b/src/main/frontend/components/cmdk.cljs @@ -409,6 +409,7 @@ [state title group visible-items first-item] (let [{:keys [show items]} (some-> state ::results deref group) highlighted-item (or @(::highlighted-item state) first-item) + highlighted-group @(::highlighted-group state) filter @(::filter state) can-show-less? (< GROUP-LIMIT (count visible-items)) can-show-more? (< (count visible-items) (count items)) @@ -427,7 +428,9 @@ [:div {:class "flex-1"}] - (when (and (or can-show-more? can-show-less?) (empty? filter)) + (when (and (= group highlighted-group) + (or can-show-more? can-show-less?) + (empty? filter)) [:a.text-link.select-node.opacity-50.hover:opacity-90 {:on-click (if (= show :more) show-less show-more)} (if (= show :more)