minor improvement

This commit is contained in:
Mega Yu
2026-03-03 15:23:21 +08:00
parent 73b6b7e0a4
commit 4fd3d8ea63
2 changed files with 13 additions and 17 deletions

View File

@@ -540,7 +540,7 @@
(when-let [item (some-> state state->highlighted-item)]
(let [page? (page-item? item)
block? (boolean (:source-block item))
shift? (event-shift? event)
shift? (event-shift? event)
shift-or-sidebar? (or shift? (boolean (:open-sidebar? (:opts state))))
search-mode (:search/mode @state/state)
graph-view? (= search-mode :graph)]
@@ -646,7 +646,7 @@
(load-results group state)
(.focus input-ref))))
(defmethod handle-action :theme [_ state]
(defmethod handle-action :theme [_ state _event]
(when-let [item (some-> state state->highlighted-item)]
(js/LSPluginCore.selectTheme (bean/->js (:source-theme item)))
(shui/dialog-close!)))
@@ -1039,14 +1039,14 @@
(reset! (::accel-start-ts state) nil))))
(defn- input-placeholder
[sidebar?]
[]
(let [search-mode (:search/mode @state/state)
action (get-action)]
(cond
(= action :move-blocks)
"Move blocks to"
(and (= search-mode :graph) (not sidebar?))
(= search-mode :graph)
"Add graph filter"
(= action :new-page)
@@ -1068,7 +1068,10 @@
(when-let [on-change (:on-input-change opts)]
(on-change new-value))))
200)
[])]
[])
debounced-composition-end (hooks/use-callback
(gfun/debounce (fn [e] (handle-input-change state e)) 100)
[])]
(hooks/use-effect! (fn []
(reset! (::all-items-cache state) (vec all-items))
(when highlighted-item
@@ -1099,13 +1102,13 @@
:auto-focus true
:autoComplete "off"
:autoCapitalize "off"
:placeholder (input-placeholder false)
:placeholder (input-placeholder)
:ref #(when-not @input-ref (reset! input-ref %))
:on-change debounced-on-change
:on-blur (fn [_e]
(when-let [on-blur (:on-input-blur opts)]
(on-blur input)))
:on-composition-end (gfun/debounce (fn [e] (handle-input-change state e)) 100)
:on-composition-end debounced-composition-end
:default-value input}]]))
(defn rand-tip

View File

@@ -65,14 +65,13 @@
[:span.cp__cmdk-current-page-badge label]))
(rum/defc root [{:keys [icon icon-theme query text info shortcut value-label value title highlighted header hoverable
compact rounded on-mounted on-click on-mouse-enter on-mouse-move source-block] :as props
compact rounded on-mounted on-click on-mouse-move source-block] :as props
:or {hoverable true rounded true}}
{:keys [app-config]}]
(let [highlight-query (partial highlight-query* app-config query)
badge-placement (current-page-badge-placement props)
text-badge (current-page-badge-node (:text-badge badge-placement))
header-badge (current-page-badge-node (:header-badge badge-placement))
[hover? set-hover?] (rum/use-state false)
keyboard-highlighted? (and highlighted (not hoverable))]
[:div (merge
{:style {:opacity 1}
@@ -87,13 +86,7 @@
compact (str " py-1.5 px-3 gap-0.5"))
:ref (when on-mounted on-mounted)
:on-click (when on-click on-click)
:on-mouse-enter (when on-mouse-enter
(fn [e]
(set-hover? true)
(on-mouse-enter e))
#(set-hover? true))
:on-mouse-move (when on-mouse-move on-mouse-move)
:on-mouse-leave #(set-hover? false)})
:on-mouse-move (when on-mouse-move on-mouse-move)})
;; header
(when header
[:div.text-xs.pl-8.font-light.flex.items-center.gap-2.flex-wrap {:class "-mt-1"
@@ -134,5 +127,5 @@
[:span.text-gray-11 (to-string value)])])
(when shortcut
[:div {:class "flex gap-1"
:style {:opacity (if (or highlighted hover?) 1 0.9)}}
:style {:opacity (if highlighted 1 0.9)}}
(shui/shortcut shortcut)])]]))