This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-10-30
Channels
- # announcements (1)
- # babashka (15)
- # calva (3)
- # cider (1)
- # clj-kondo (16)
- # clj-on-windows (1)
- # cljfx (1)
- # clojure (25)
- # clojure-europe (6)
- # clojure-spec (15)
- # cursive (13)
- # emacs (11)
- # fulcro (2)
- # humbleui (7)
- # introduce-yourself (1)
- # jackdaw (1)
- # off-topic (10)
- # pathom (5)
- # portal (3)
- # re-frame (7)
- # reagent (12)
- # releases (1)
- # shadow-cljs (8)
- # tools-build (18)
- # web-security (10)
Hello! I want to focus an html input element using a button's on-click event. I've managed to achieve this by storing a :ref
in an atom and using (-> @input .focus)
in the button's :on-click
, everything implemented in a form-2 component, so far so good. The thing is, that I also want to show the input element on the button click first (I achieve that with :class
) and then focus the element. I suppose the problem is that when the button is clicked re-agent needs a few cycles to update the dom and for .focus to be effective I need to call it after the dom has been updated / input has been shown. Any ideas?
I currently solved this using a js/setTimeout focus 1 but it seems a little bit non-deterministic
There's no practical reason to avoid them, unless you have an alternative that's shorter and not worse in some way. In this case, I don't know of any alternative.
I’m not sure if this has been answered or not but putting a good key on the the input does a lot to improving that sort of behavior
for instance that way you don’t lose focus when typing into an input field with a controlled value
For those (like me) who like an online conversion tool for HTML (e.g. Tailwind components) to Hiccup:
https://html2hiccup.dev/
As opposed to some of the existing tools it:
• It preserves the SVG attribute viewBox
as camel case.
• It converts HTML comments ( <!-- the HTML comment -->
) into Clojure comments: (comment "the HTML comment")
• It doesn't generate invalid Hiccup when dealing with empty attributes like <a href="">Hello</a>
Other than adding a button to easily copy the hiccup to the clipboard, I don't plan to add anything else.
I hope others will find it useful.
Thanks for this! My go to converter is down https://htmltohiccup.herokuapp.com/ and yours came at a perfect time.