Skip to content

Commit

Permalink
Fix selection behavior for merged cells
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Jun 19, 2024
1 parent 3182693 commit ab4004b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/bean/ui/views/sheet.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,11 @@
(.clear (:selection @pixi-app))
(selection->rect (:selection @pixi-app) area row-heights col-widths))

(defn- grid-selection-start [start grid-g row-heights col-widths pixi-app]
(let [i->area #(let [rc (i->rc % grid-g row-heights col-widths)]
(defn- grid-selection-start [sheet rc grid-g row-heights col-widths pixi-app]
(let [start (util/merged-or-self rc sheet)
i->area #(let [rc (util/merged-until-or-self
(i->rc % grid-g row-heights col-widths)
sheet)]
(area/bounds->area start rc))]
(reset-listener!
:grid-selection-move grid-g "globalpointermove"
Expand All @@ -131,14 +134,13 @@
(defn- cell-pointer-down [rc grid-g sheet row-heights col-widths pixi-app]
(submit-cell-input)
(rf/dispatch [::events/clear-edit-cell])
(rf/dispatch-sync [::events/set-selection {:start rc :end rc}])
(rf/dispatch-sync [::events/set-selection {:start (util/merged-or-self rc sheet)
:end (util/merged-until-or-self rc sheet)}])
(when (and (< (- (js/Date.now) (:time @last-click)) 300)
(= (:rc @last-click) rc))
(cell-double-click rc sheet))
(reset! last-click {:time (js/Date.now) :rc rc})
(grid-selection-start
(util/merged-or-self rc sheet)
grid-g row-heights col-widths pixi-app))
(grid-selection-start sheet rc grid-g row-heights col-widths pixi-app))

(defn- grid-pointer-down [i grid-g sheet row-heights col-widths pixi-app]
(let [rc (i->rc i grid-g row-heights col-widths)]
Expand Down Expand Up @@ -774,8 +776,7 @@
:line-height (str (- (cell-h r cell row-heights) 12) "px")
:background-color (when background (util/color-int->hex background))
:fontWeight (if bold? "bold" "normal")}
:on-pointer-down #(grid-selection-start
(util/merged-or-self [r c] sheet)
:on-pointer-down #(grid-selection-start sheet [r c]
(:grid @pixi-app) row-heights col-widths pixi-app)
:on-pointer-up #(let [canvas (.querySelector js/document "#grid-container canvas")]
(.dispatchEvent canvas (new js/MouseEvent "pointerup" %)))
Expand Down

0 comments on commit ab4004b

Please sign in to comment.