Skip to content

Commit

Permalink
Guard clause for edit cell
Browse files Browse the repository at this point in the history
  • Loading branch information
prabhanshuguptagit committed Jun 29, 2024
1 parent 8d62f7a commit fdf315f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/bean/ui/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@
(rf/reg-event-fx
::edit-cell
(fn edit-cell [{:keys [db]} [_ rc text]]
(let [rc* (util/merged-or-self rc (:sheet db))
content (get-in db (flatten [:sheet :grid rc* :content]))]
{:db (assoc-in db [:ui :grid :editing-cell] rc*)
:fx [[:dispatch [::set-selection {:start rc* :end (util/merged-until-or-self rc* (:sheet db))}]]
[::focus-element ["cell-input" (or text content)]]]})))
(let [rc* (util/merged-or-self rc (:sheet db))]
(when (get-in db (flatten [:sheet :grid rc*]))
(let [content (get-in db (flatten [:sheet :grid rc* :content]))]
{:db (assoc-in db [:ui :grid :editing-cell] rc*)
:fx [[:dispatch [::set-selection {:start rc* :end (util/merged-until-or-self rc* (:sheet db))}]]
[::focus-element ["cell-input" (or text content)]]]})))))

(rf/reg-event-db
::clear-edit-cell
Expand Down

0 comments on commit fdf315f

Please sign in to comment.