This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-01
Channels
- # aatree (1)
- # admin-announcements (11)
- # beginners (77)
- # boot (73)
- # braid-chat (29)
- # cbus (3)
- # clara (3)
- # cljs-dev (16)
- # cljsjs (2)
- # cljsrn (68)
- # clojure (149)
- # clojure-austin (1)
- # clojure-czech (2)
- # clojure-miami (8)
- # clojure-poland (28)
- # clojure-russia (165)
- # clojure-ukraine (1)
- # clojurebridge (3)
- # clojurescript (64)
- # community-development (1)
- # core-async (27)
- # core-matrix (2)
- # cursive (38)
- # data-science (2)
- # datavis (4)
- # datomic (3)
- # dirac (78)
- # emacs (10)
- # events (1)
- # funcool (6)
- # hoplon (25)
- # immutant (2)
- # jobs (3)
- # ldnclj (34)
- # luminus (4)
- # mount (23)
- # off-topic (26)
- # om (121)
- # onyx (320)
- # other-lisps (1)
- # proton (13)
- # re-frame (33)
- # yada (3)
@sooheon: I guess what you could do is in the on-change dispatch to do nothing unless all characters are complete characters. Or alternatively ignore all on-change and use only on-blur.
@sooheon are you using :value
or :default-value
on the input? I guess :value could cause this behavior
@nberger: using :default-value
how would you reset the input's value from the outside?
@mbertheau I guess you have to rely on something else. But in many cases you don't need to do that. In this particular case, is it needed to be able to reset the value from the outside, after the initial render of the component?
the purpose of the event is to add the value of a clickable var into the currently focused input
I hoped that the on-change event on the updated input field would trigger when the text changes but it doesn't
I don't like the approach but I'm not sure if there is a way to achieve this with handlers
@mbertheau do you know of any example of similar paste function ?
@yenda: And you have two problems doing that the re-frame way - finding the right spot in app-db for activeElement
and knowing the selection to insert in the right position, correct?
@yenda: maybe in the component you could add a callback to the DOM element that dispatches the on-change manually and call that in on-mouse-down
.
@mbertheau: yes that is exactly my two problems
@mbertheau: I'm resetting :default-value
using the will-receive-props
react element method
like this:
(let [state (reagent/atom {:value (or default-value "")})]
(reagent/create-class
{:component-will-receive-props
(fn [_ [_ props]]
(let [default-value (:default-value props)
state-value (:value @state)]
(when (not= default-value state-value)
(swap! state assoc :value default-value))))
This changes the value from my component state when the wrapper component changes the default-value it is passing to it
My use case is that I have a generic input with state
And want to control it's value sometimes (e.g. search query string changes)