mirror of
https://github.com/logseq/logseq.git
synced 2026-04-27 07:35:01 +00:00
fix: esc to exit filter first and then clear the input
This commit is contained in:
@@ -131,10 +131,14 @@
|
||||
(= input (util/page-name-sanity-lc (:block/title block))))) blocks-result))))
|
||||
include-slash? (or (string/includes? input "/")
|
||||
(string/starts-with? input "/"))
|
||||
start-with-slash? (string/starts-with? input "/")
|
||||
order* (cond
|
||||
(= search-mode :graph)
|
||||
[]
|
||||
|
||||
start-with-slash?
|
||||
[["Filters" :filters (visible-items :filters)]]
|
||||
|
||||
include-slash?
|
||||
[(when-not node-exists?
|
||||
["Create" :create (create-items input)])
|
||||
@@ -561,8 +565,11 @@
|
||||
|
||||
(defmethod handle-action :filter [_ state _event]
|
||||
(let [item (some-> state state->highlighted-item)
|
||||
!input (::input state)]
|
||||
(reset! !input (get-filter-user-input @!input))
|
||||
!input (::input state)
|
||||
input-ref @(::input-ref state)]
|
||||
(let [value (get-filter-user-input @!input)]
|
||||
(reset! !input value)
|
||||
(set! (.-value input-ref) value))
|
||||
(let [!filter (::filter state)
|
||||
group (get-in item [:filter :group])]
|
||||
(swap! !filter assoc :group group)
|
||||
@@ -782,13 +789,14 @@
|
||||
(handle-action :default state e)
|
||||
(util/stop-propagation e))
|
||||
esc? (let [filter' @(::filter state)]
|
||||
(when-not (string/blank? input)
|
||||
(util/stop e)
|
||||
(handle-input-change state nil ""))
|
||||
(when (and filter' (string/blank? input))
|
||||
(util/stop e)
|
||||
(reset! (::filter state) nil)
|
||||
(load-results :default state)))
|
||||
(if filter'
|
||||
(do
|
||||
(util/stop e)
|
||||
(reset! (::filter state) nil)
|
||||
(load-results :default state))
|
||||
(when-not (string/blank? input)
|
||||
(util/stop e)
|
||||
(handle-input-change state nil ""))))
|
||||
(and meta? (= keyname "c")) (do
|
||||
(copy-block-ref state)
|
||||
(util/stop-propagation e))
|
||||
@@ -851,23 +859,12 @@
|
||||
(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-key-down (gfun/debounce
|
||||
(fn [e]
|
||||
(p/let [value (.-value @input-ref)
|
||||
last-char (last value)
|
||||
backspace? (= (util/ekey e) "Backspace")
|
||||
filter-group (:group @(::filter state))
|
||||
slash? (= (util/ekey e) "/")
|
||||
namespace-pages (when (and slash? (contains? #{:whiteboards} filter-group))
|
||||
(search/block-search (state/get-current-repo) (str value "/") {}))
|
||||
namespace-page-matched? (some #(string/includes? % "/") namespace-pages)]
|
||||
(when (and filter-group
|
||||
(or (and slash? (not namespace-page-matched?))
|
||||
(and backspace? (= last-char "/"))
|
||||
(and backspace? (= input ""))))
|
||||
(reset! (::filter state) nil)
|
||||
(load-results :default state))))
|
||||
100)
|
||||
:on-key-down (fn [e]
|
||||
(case (util/ekey e)
|
||||
"Esc"
|
||||
(when-not @(::filter state)
|
||||
(shui/dialog-close!))
|
||||
nil))
|
||||
:default-value input}]]))
|
||||
|
||||
(defn rand-tip
|
||||
@@ -1047,14 +1044,13 @@
|
||||
(and (contains? #{:create} group-filter)
|
||||
(= group-key :create))))))
|
||||
results-ordered)]
|
||||
(when-not (= ["Filters"] (map first items))
|
||||
(if (seq items)
|
||||
(for [[group-name group-key _group-count group-items] items]
|
||||
(let [title (string/capitalize group-name)]
|
||||
(result-group state title group-key group-items first-item sidebar?)))
|
||||
[:div.flex.flex-col.p-4.opacity-50
|
||||
(when-not (string/blank? @*input)
|
||||
"No matched results")])))]
|
||||
(if (seq items)
|
||||
(for [[group-name group-key _group-count group-items] items]
|
||||
(let [title (string/capitalize group-name)]
|
||||
(result-group state title group-key group-items first-item sidebar?)))
|
||||
[:div.flex.flex-col.p-4.opacity-50
|
||||
(when-not (string/blank? @*input)
|
||||
"No matched results")]))]
|
||||
(when-not sidebar? (hints state))]))
|
||||
|
||||
(rum/defc cmdk-modal [props]
|
||||
|
||||
Reference in New Issue
Block a user