Skip to content

Commit

Permalink
fix: prevent default browser behavior for tab and shift+tab when ther…
Browse files Browse the repository at this point in the history
…e is no indent or unindent happening (athensresearch#209)

Co-authored-by: Adrien Lacquemant <github@alaq.io>
Co-authored-by: nthd3gr33 <codinginenglish@gmail.com>
  • Loading branch information
3 people committed Jul 8, 2020
1 parent e461ead commit 944fddd
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions src/cljs/athens/views/blocks.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,10 @@
(and (= key-code KeyCodes.RIGHT) block-end?) (dispatch [:right uid])

;; -- Tab ----------------------------------------------------------------
(and shift (= key-code KeyCodes.TAB)) (dispatch [:unindent uid])
(= key-code KeyCodes.TAB) (dispatch [:indent uid])
(and shift (= key-code KeyCodes.TAB)) (do (.. e preventDefault)
(dispatch [:unindent uid]))
(= key-code KeyCodes.TAB) (do (.. e preventDefault)
(dispatch [:indent uid]))

;; -- Enter --------------------------------------------------------------

Expand Down Expand Up @@ -455,30 +457,30 @@
:on-change (fn [_] (db-on-change (:atom-string @state) uid))
:on-key-down (fn [e] (on-key-down e uid state))}]
[parse-and-render string]


;; Slash menu
(when (:slash? @state)
[slash-menu-component {:style {:position "absolute"
:top "100%"
:left "-0.125em"}}])
(when (:slash? @state)
[slash-menu-component {:style {:position "absolute"
:top "100%"
:left "-0.125em"}}])

;; Page search menu
(when (:search/page @state)
(let [query (:search/query @state)
results (when (not (str/blank? query))
(db/search-in-node-title query))]
[dropdown {:style {:position "absolute"
:top "100%"
:left "-0.125em"}
:content
(if (not query)
[:div "Start Typing!"]
(for [{:keys [node/title block/uid]} results]
^{:key uid}
[:div {:on-click #(navigate-uid uid)} title]))}]))
(when (:search/page @state)
(let [query (:search/query @state)
results (when (not (str/blank? query))
(db/search-in-node-title query))]
[dropdown {:style {:position "absolute"
:top "100%"
:left "-0.125em"}
:content
(if (not query)
[:div "Start Typing!"]
(for [{:keys [node/title block/uid]} results]
^{:key uid}
[:div {:on-click #(navigate-uid uid)} title]))}]))



;; Drop Indicator
(when (and (= closest-uid uid)
Expand Down

0 comments on commit 944fddd

Please sign in to comment.