Fork me on GitHub
#reagent
<
2017-11-20
>
mikerod00:11:34

@gonewest818 it isn’t clear to me why the default wouldn’t do what you expect

mikerod00:11:31

If the sa/Select doesn’t work, but :select does though, you may wan tto look at the generated html

mikerod00:11:58

See what sa/Select is producing. I’m not the most qualified to answer this though since I haven’t used these semantic-ui components myself yet

mikerod00:11:12

You could do something like controlling all your values

mikerod00:11:18

and then build your own :on-submit

mikerod00:11:51

Most of the time the pattern seems to be all controlled input, no default behavior for form submission due to typically wanting something like an async request

mikerod00:11:23

Not sure all your specifics. However, I’d think the simple and default behavior would work if you aren’t somehow controlling certain components in a way that is preventing the default DOM state from happening

gonewest81800:11:27

I did look at the html. I think it’s because a “sa/Form” isn’t a “<form>“, neither is a “sa/Select” a “<select>“. They’re divs with CSS and some custom javascript doing whatever it is they do. I haven’t looked at the react bootstrap components but I wouldn’t be surprised if the situation is similar.

gonewest81800:11:33

Anyway, answering my own question, I guess my handler will end up something like (set! js/window.location.href (format "/?foo=%&bar=%" a b))

gonewest81800:11:03

And I’m really not doing anything all that tricky in the components (because I’m new at this).

mikerod00:11:05

Are you wanting the page to navigate away?

mikerod00:11:43

Yeah, if they are making <div> etc, I’d think you’d have to take control of the submission

mikerod00:11:03

To get the correct values placed on the query param names you want

gonewest81800:11:08

yes, that seems to be the case. Alright, I’ll take control of the submission for now. Later, I may choose to rip this out and not navigate away, but I might as well complete this journey before taking the next. thanks

mikerod02:11:38

Ok, sounds good

mikerod02:11:46

Sorry I can’t be a whole lot more help in that case.

mikerod02:11:06

The author of the soda-ash project is on this channel though I believe from time to time

gonewest81802:11:59

All good, problem solved.

gonewest81802:11:28

I switched everything back to the soda-ash variants like so:

[sa/Form
  [sa/Input ...]
  [sa/Select ...]
  [sa/Button {:on-click #(set! js/window.location.href ...)]]
where the on-click handler is formatting the url parameters the way I need.

mikerod03:11:35

Ok, interesting

gadfly36106:11:47

@gonewest818 happy you were able to figure it out!

minikomi09:11:18

What's people's go-to for enter/exit transitions these days? Every time I try to mix in react-motion the mix of js/cljs props makes things super painful

mikethompson12:11:39

@minikomi we ended up using react-flip-move but I haven't looked at this space in a year, so there might be shiny new things available

gadfly36112:11:23

I have used react-flip-move based on a previous recommendation from @mikethompson and i can say it works great!

olivermooney13:11:28

Does anyone have any experience using https://github.com/atlassian/react-beautiful-dnd via reagent? They use a redux-style connect strategy to co-ordinate dragging & dropping and I’m having trouble translating their basic example into clojurescript & reagent code

olivermooney13:11:53

I’m using a combination of (as-element ...) and (get-props (current-component) to try and switch between reagent and react as needed

olivermooney13:11:48

But one of my current-component calls is returning nil so I’ve no idea how to get the current component instance or the react equivalent

olivermooney13:11:40

For info, a self-contained version of my code would be:

(defn dnd
  []
  [:> Dnd.DragDropContext {:onDragStart on-drag-start :onDragEnd on-drag-end}
   [:div
    [:> Dnd.Droppable {:droppableId "library" :isDropDisabled true}
     (fn [provided snapshot]
       (r/as-element
        [:div {:ref (.-innerRef provided)}
         (for [{:keys [id content] :as item} [{ :id 1 :content "First" } { :id 2 :content "Second" } { :id 3 :content "Third" }] ]
           (r/as-element
            [:> Dnd.Draggable {:key id :draggableId id}
             (fn [provided snapshot]
               (.log js/console provided snapshot)
               (r/as-element
                [:div
                 (do
                   (.log js/console (r/current-component)) ;; FIXME can't get current component as in react land, not reagent land. Crashes at this point
                   (let [handle-props (r/props (r/current-component))] ;; FIXME: probably need to log this stuff to see what it looks like
                     (.log js/console handle-props);
                     (r/as-element
                      [:div (merge handle-props {:ref (.-innerRef provided)})
                       (r/as-element
                        [lib-fragment id content])
                       ])))
                 (.-placeholder provided)]))]))]))]]])

olivermooney13:11:37

(following the example on the react-beautiful-dnd homepage, I’d normally have much shorter fns…)

eveko15:11:27

Hello, how can I change the value of :active in my nav items? just altering the ratom does not seam to work... Sorry for the beginner question

eveko15:11:32

here is my snippet

mikerod15:11:40

@eveko One thing I noticed, is you have def menu instead of defn menu []

mikerod15:11:46

Was that just a typo of pasting the example?

eveko15:11:29

no it is a def

eveko15:11:05

otherwise i can put it in the main [:div.header menu]

eveko15:11:08

inf my main fn

mikerod15:11:27

@eveko than I think that is your problem

mikerod15:11:00

you have to deref reactive atoms (aka “ratoms” (aka r/atom )) during the rendering of a component

mikerod15:11:18

(defn menu [] <etc>)

eveko15:11:25

it works now

mikerod15:11:25

[:divheader [menu]]

eveko15:11:50

if feel so silly now

eveko15:11:14

thanks for the quick fix

mikerod16:11:08

No problem!