Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Indent keeps focus #2346

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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