This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-03-02
Channels
- # announcements (25)
- # babashka (76)
- # beginners (74)
- # biff (36)
- # calva (11)
- # cider (5)
- # clerk (43)
- # cljs-dev (4)
- # cljsrn (12)
- # clojure (111)
- # clojure-austin (14)
- # clojure-europe (82)
- # clojure-nl (2)
- # clojure-norway (5)
- # clojure-uk (1)
- # clojurescript (36)
- # core-async (13)
- # cursive (30)
- # datomic (12)
- # fulcro (6)
- # honeysql (9)
- # hyperfiddle (73)
- # instaparse (3)
- # introduce-yourself (1)
- # membrane (40)
- # nbb (2)
- # off-topic (6)
- # other-languages (9)
- # polylith (33)
- # reagent (2)
- # reitit (7)
- # rum (7)
- # shadow-cljs (47)
- # tools-deps (10)
- # vim (11)
- # xtdb (16)
I am rendereing a map of components, and for each one, I am using a key/bind function that should work only for this component. Howevever, I am using reagent to render them in a React Swipeable, so they are all mounted together, but one-by-one is shown. What is a way of only using the on-keyboard-on! and on-keyboard-off! accordingly? So my components are different fields, but when it is bool-field, I am using keyboard-listener. The thing is, it at first gets the correct index, then it renders the one with the wrong index, like in page 6
(defn bool-field [{:keys [field-id input-data]}]
(let [text-val (r/atom (:value (get input-data (keyword field-id))))
visible? (r/atom false)]
(fn [{:keys [field-id form-messages on-submit regenerate-display-fields
field index theme-data current-page input-data]}]
(if (= @current-page index)
(keyboard-listener-on! {:text-val text-val
:true-letter (lower-case (first (:yes_button_text form-messages)))
:false-letter (lower-case (first (:no_button_text form-messages)))
:input-data input-data :field-id field-id
:current-page current-page :index index
:regenerate-display-fields regenerate-display-fields :on-submit on-submit})
(keyboard-listener-off! {:true-letter (lower-case (first (:yes_button_text form-messages)))
:false-letter (lower-case (first (:no_button_text form-messages)))}))
[v-box
:width "100%"
:align :center
:justify :center
:children [[:div
[boolean-fields-area {:form-messages form-messages :text-val text-val :theme-data theme-data :field field
:input-data input-data :field-id field-id :current-page current-page :index index
:regenerate-display-fields regenerate-display-fields :on-submit on-submit}]
[:div {:class (warning-notification {:width "327px"})}
(calc-error-message {:type "boolean" :field field :form-messages form-messages})]]]])))