Skip to content

Commit

Permalink
fix: buggy selection hightlights (logseq#9074)
Browse files Browse the repository at this point in the history
  • Loading branch information
tiensonqin authored Apr 12, 2023
1 parent 0edb4f5 commit 339fb7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/main/frontend/components/block.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1713,7 +1713,7 @@
(or ref? query?)
(assoc :ref-query-child? true))]
(rum/with-key (block-container config child)
(:block/uuid child)))))]])))
(str (:blocks-container-id config) "-" (:block/uuid child))))))]])))

(defn- block-content-empty?
[{:block/keys [properties title body]}]
Expand Down Expand Up @@ -2791,7 +2791,8 @@
edit? (state/sub [:editor/editing? edit-input-id])
card? (string/includes? data-refs-self "\"card\"")
review-cards? (:review-cards? config)
selected? (when-not slide? (state/sub-block-selected? uuid))]
selected? (when-not slide?
(state/sub-block-selected? blocks-container-id uuid))]
[:div.ls-block
(cond->
{:id block-id
Expand Down Expand Up @@ -3276,7 +3277,7 @@
:block/bottom? (= (count blocks) (inc idx))))
config (assoc config :block/uuid (:block/uuid item))]
(rum/with-key (block-container config item)
(str (:block/uuid item)))))
(str (:blocks-container-id config) "-" (:block/uuid item)))))

(defn- block-list
[config blocks]
Expand Down
4 changes: 2 additions & 2 deletions src/main/frontend/state.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -631,9 +631,9 @@ Similar to re-frame subscriptions"
(distinct)))

(defn sub-block-selected?
[block-uuid]
[container-id block-uuid]
(rum/react
(rum/derived-atom [state] [::select-block block-uuid]
(rum/derived-atom [state] [::select-block container-id block-uuid]
(fn [state]
(contains? (set (get-selected-block-ids (:selection/blocks state)))
block-uuid)))))
Expand Down

0 comments on commit 339fb7c

Please sign in to comment.