Fork me on GitHub
#reagent
<
2015-09-25
>
lancefalcon11:09:54

Anyone managing focus in reagent with success? I.e. set the focus programmatically without the use of IDs

mccraigmccraig11:09:44

@lancefalcon: what's wrong with IDs ?

lancefalcon11:09:36

mccraigmccraig: makes my components non-reusable

mccraigmccraig11:09:26

@lancefalcon: when i need an id, i use a form-2 component, with (let [my-id (gensym "blahblah-")] ...) in the outer function

lancefalcon11:09:39

oh, gensym works at runtime as well?

lancefalcon11:09:47

that'll work, thanks a lot simple_smile

mitchelkuijpers12:09:33

gensym nice one thnx

mikethompson13:09:09

@lancefalcon [:input {:autofocus true ...} ....] will set focus the first time it renders

mikethompson13:09:47

or is that auto-focus ?

mikethompson13:09:06

something like that

timgilbert15:09:12

Yeah, {:auto-focus true} has been working fine for me.

gadfly36116:09:03

@lancefalcon you can use dom-node instead of an id a lot of the time, and if you want it past the first render, you can use a lifecycle hook: https://github.com/tastejs/todomvc/blob/master/examples/reagent/src/cljs/todomvc/components/todo_edit.cljs