Skip to content

Commit

Permalink
fix: disable page/block preview when editing
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin committed May 25, 2022
1 parent 4152c3e commit f3ed5e6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
6 changes: 5 additions & 1 deletion src/main/frontend/components/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@

(if (or (not manual?) open?)
(ui/tippy {:ref *tippy-ref
:in-editor? true
:html html-template
:interactive true
:delay [1000, 100]
Expand Down Expand Up @@ -761,6 +762,7 @@
(db/get-block-and-children repo block-id)
(assoc config :id (str id) :preview? true))]])
:interactive true
:in-editor? true
:delay [1000, 100]} inner)
inner)])
[:span.warning.mr-1 {:title "Block ref invalid"}
Expand Down Expand Up @@ -1056,7 +1058,8 @@
(when-not (string/blank? query)
(custom-query (assoc config :dsl-query? true)
{:title (ui/tippy {:html commands/query-doc
:interactive true}
:interactive true
:in-editor? true}
[:span.font-medium.px-2.py-1.query-title.text-sm.rounded-md.shadow-xs
(str "Query: " query)])
:query query})))])
Expand Down Expand Up @@ -1981,6 +1984,7 @@
(for [clock (take 10 (reverse clocks))]
[:li clock])]])))
:interactive true
:in-editor? true
:delay [1000, 100]}
[:div.text-sm.time-spent.ml-1 {:style {:padding-top 3}}
[:a.fade-link
Expand Down
10 changes: 6 additions & 4 deletions src/main/frontend/ui.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -787,20 +787,22 @@
:checked selected}]
label])]))

(rum/defcs tippy < rum/static
(rum/defcs tippy < rum/reactive
(rum/local false ::mounted?)
[state {:keys [fixed-position? open?] :as opts} child]
[state {:keys [fixed-position? open? in-editor?] :as opts} child]
(let [*mounted? (::mounted? state)
mounted? @*mounted?
manual (not= open? nil)]
manual (not= open? nil)
editing? (state/sub :editor/editing?)]
(Tippy (->
(merge {:arrow true
:sticky true
:delay 600
:theme "customized"
:disabled (not (state/enable-tooltip?))
:unmountHTMLWhenHide true
:open (if manual open? @*mounted?)
:open (when-not (and in-editor? editing?)
(if manual open? @*mounted?))
:trigger (if manual "manual" "mouseenter focus")
;; See https://github.com/tvkhoa/react-tippy/issues/13
:popperOptions {:modifiers {:flip {:enabled (not fixed-position?)}
Expand Down

0 comments on commit f3ed5e6

Please sign in to comment.