Skip to content

Commit

Permalink
fix: hack to avoid text blink
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed Aug 24, 2022
1 parent 9f92101 commit cc49f56
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/electron/listener.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@
(let [data' (bean/->clj data)]
(state/set-state! [:ui/find-in-page :matches] data')
(dom/remove-style! (dom/by-id "search-in-page-input") :visibility)
(dom/set-text! (dom/by-id "search-in-page-placeholder") "")
(ui/focus-element "search-in-page-input")
true)))

Expand Down
3 changes: 2 additions & 1 deletion src/main/frontend/components/find_in_page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
[:div.text-sm.absolute.top-2.right-0.py-2.px-4
(:activeMatchOrdinal matches 0)
"/"
total]))])
total]))
[:div#search-in-page-placeholder.absolute.top-2.left-0.p-2.sm:text-sm]])

(rum/defc search-inner < rum/static
(mixins/event-mixin
Expand Down
6 changes: 6 additions & 0 deletions src/main/frontend/handler/search.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@
(when-not (string/blank? q)
(dom/set-style! (dom/by-id "search-in-page-input")
:visibility "hidden")
(when (> (count q) 1)
(dom/set-html! (dom/by-id "search-in-page-placeholder")
(util/format
"<span><span>%s</span><span style=\"margin-left: -4px;\">%s</span></span>"
(first q)
(str " " (subs q 1)))))
(ipc/ipc "find-in-page" q option)))))

(defonce debounced-search (debounce electron-find-in-page! 500))
Expand Down

0 comments on commit cc49f56

Please sign in to comment.