Skip to content

Commit

Permalink
Merge pull request athensresearch#2346 from neotyk/dev/task-indent-lo…
Browse files Browse the repository at this point in the history
…osing-focus

fix: Indent keeps focus
  • Loading branch information
filipesilva authored Sep 6, 2022
2 parents 7c24c30 + af05226 commit 4eb6b5e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/cljs/athens/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,7 @@

(reg-event-fx
:indent
(fn [{:keys [_db]} [_ {:keys [uid d-key-down local-string] :as args}]]
(fn [{:keys [_db]} [_ {:keys [uid d-key-down local-string editing-uid] :as args}]]
;; - `block-zero`: The first block in a page
;; - `value` : The current string inside the block being indented. Otherwise, if user changes block string and indents,
;; the local string is reset to original value, since it has not been unfocused yet (which is currently the
Expand Down Expand Up @@ -1246,7 +1246,7 @@
(when (and prev-block-uid
(not first-block?))
{:fx [(transact-async-flow :indent event sentry-tx [])
[:set-cursor-position [uid start end]]
[:set-cursor-position [(or editing-uid uid) start end]]
[:dispatch-n (cond-> []
(seq new-titles)
(conj [:reporting/page.create {:source :indent
Expand Down Expand Up @@ -1282,7 +1282,7 @@

(reg-event-fx
:unindent
(fn [{:keys [_db]} [_ {:keys [uid d-key-down context-root-uid embed-id local-string] :as args}]]
(fn [{:keys [_db]} [_ {:keys [uid d-key-down context-root-uid embed-id local-string editing-uid] :as args}]]
(log/debug ":unindent args" (pr-str args))
(let [sentry-tx (close-and-get-sentry-tx "unindent")
db @db/dsdb
Expand Down Expand Up @@ -1313,8 +1313,8 @@
event (common-events/build-atomic-event block-save-block-move-op)]
(log/debug ":unindent do-nothing?" do-nothing?)
(when-not do-nothing?
{:fx [(transact-async-flow :unindent event sentry-tx [(focus-on-uid uid embed-id)])
[:set-cursor-position [uid start end]]
{:fx [(transact-async-flow :unindent event sentry-tx [(focus-on-uid (or editing-uid uid) embed-id)])
[:set-cursor-position [(or editing-uid uid) start end]]
[:dispatch-n (cond-> []
(seq new-titles)
(conj [:reporting/page.create {:source :unindent
Expand Down
2 changes: 2 additions & 0 deletions src/cljs/athens/views/blocks/textarea_keydown.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -520,11 +520,13 @@
(tab-handler uid embed-id d-key-down)
(if shift
(dispatch [:unindent {:uid (or navigation-uid uid)
:editing-uid uid
:d-key-down d-key-down
:context-root-uid current-root-uid
:embed-id embed-id
:local-string local-string}])
(dispatch [:indent {:uid (or navigation-uid uid)
:editing-uid uid
:d-key-down d-key-down
:local-string local-string}]))))))

Expand Down

0 comments on commit 4eb6b5e

Please sign in to comment.