... | ... |
@@ -121,6 +121,13 @@ |
121 | 121 |
(fn [cmd [_ idx]] |
122 | 122 |
(assoc-in cmd [:suggestions :selected] idx))) |
123 | 123 |
|
124 |
+(re-frame/reg-event-fx |
|
125 |
+ ::click-suggestion |
|
126 |
+ (fn [cofx [_ prompt cmd]] |
|
127 |
+ (let [db (cofx :db)] |
|
128 |
+ {:db (assoc-in db [:cmdline :current] cmd) |
|
129 |
+ :fx [[:dispatch [::submit-cmd prompt]]]}))) |
|
130 |
+ |
|
124 | 131 |
(re-frame/reg-event-db |
125 | 132 |
::prompt-keypress |
126 | 133 |
(re-frame/path :cmdline) |
... | ... |
@@ -61,8 +61,11 @@ |
61 | 61 |
(for [[idx x] (enumerated options)] |
62 | 62 |
^{:key x} [:li |
63 | 63 |
{:class (when (= idx selected) :selected) |
64 |
- :on-mouse-enter #(re-frame/dispatch [::events/hover-suggestion idx])} |
|
65 |
- |
|
64 |
+ :on-mouse-enter #(re-frame/dispatch [::events/hover-suggestion idx]) |
|
65 |
+ :on-click #(do (.preventDefault %) |
|
66 |
+ (re-frame/dispatch [::events/click-suggestion |
|
67 |
+ (-> % .-target .-parentElement .-parentElement) |
|
68 |
+ x]))} |
|
66 | 69 |
x]))]])) |
67 | 70 |
|
68 | 71 |
(defn title [] |