This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-10-25
Channels
- # announcements (14)
- # aws (1)
- # babashka (23)
- # beginners (442)
- # calva (50)
- # chlorine-clover (1)
- # cider (32)
- # clojure (124)
- # clojure-europe (35)
- # clojure-france (5)
- # clojure-gamedev (5)
- # clojure-nl (2)
- # clojure-portugal (3)
- # clojure-uk (4)
- # clojurescript (56)
- # conjure (5)
- # cursive (24)
- # datalevin (1)
- # datomic (57)
- # fulcro (35)
- # helix (15)
- # holy-lambda (8)
- # introduce-yourself (1)
- # jobs (5)
- # kaocha (1)
- # lsp (99)
- # malli (10)
- # music (1)
- # off-topic (22)
- # pathom (38)
- # podcasts-discuss (10)
- # polylith (10)
- # reitit (1)
- # releases (1)
- # remote-jobs (4)
- # shadow-cljs (18)
- # spacemacs (6)
- # tools-build (22)
- # vim (66)
- # xtdb (22)
@ghaskins Does the text input component works in v5, or did the old v4 trick work? I want to make the migration as well, any hint would be welcomed!
It doesn't work, and the old trick does not work, if by work you mean allows you to edit text without cursor jumping
I ended up crafting my own solution which seems to hang together
Can you share your solution? :)
hi @neo2551 @ghaskins sorry I haven't been around much in the last week or so have extracted a very rough cut of what I have below
(defn controlled-text-field []
(let [cursor-position (atom nil)]
(reagent/create-class
{:component-did-update (fn [this]
(let [dom-node (rdom/dom-node this)
input (aget (.getElementsByTagName dom-node "input") 0)]
(.setSelectionRange input @cursor-position @cursor-position)))
:reagent-render
(fn []
[:> TextField
{:label "controlled text field"
:type "text"
:fullWidth true
:size "small"
:value
(or
@(re-frame/subscribe [::subs/my-sub])
"")
:onChange
(fn [event]
(reset! cursor-position (-> event .-target .-selectionStart))
(re-frame/dispatch
[::events/update-value (-> event .-target .-value)])
)}])})))
it seems to hang together
but I make no real claims for reliability !
Hey, I'm in the midst of migrating a cljs project to shadow-cljs. Everything is working fine, except that I am not able to run tests. The docs suggest that it is enough to add test namespaces with -test
prefix but the following configuration does not seem to work when running npx shadow-cljs compile test
. The build completes without errors but zero tests are run. Do I need to setup a custom test runner for this?
[:test] Compiling ...
------ ERROR -------------------------------------------------------------------
File: /mnt/c/Users/thheller/code/tmp/cljs-test/test/cljs/cljs_test/some_test.cljs:1:1
--------------------------------------------------------------------------------
1 | (ns cljs-test.some-test
-------^------------------------------------------------------------------------
null
Invalid namespace declaration
-- Syntax error -------------------
(... ... (:require [cljs.test :refer :all]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
has extra input
-- Relevant specs -------
:shadow.build.ns-form/ns-form:
(clojure.spec.alpha/cat
:ns
'#{clojure.core/ns}
:name
clojure.core/simple-symbol?
:docstring
(clojure.spec.alpha/? clojure.core/string?)
:meta
(clojure.spec.alpha/? clojure.core/map?)
:clauses
:shadow.build.ns-form/ns-clauses)
-------------------------
Detected 1 error
--------------------------------------------------------------------------------
2 | (:require [cljs.test :refer :all]))
3 |
4 | (deftest some-test
5 | (testing "that it is true"
--------------------------------------------------------------------------------
:error
Oh yeah, right, that was actually a change I made in the middle of debugging. The original require was [cljs.test :refer-macros [deftest is testing]]
but changing that to [cljs.test :refer [deftest is testing]]
fixed the issue, thanks for the help!
@neo2551 I havent tried beyond my simple login form, so far. That form in particular uses React setState for state management, and it seems that the textfields do work fine at least there. I havent tried my larger app that has r/atom based controlled inputs.
@gingerwizard id be interested in learning about your solution, if you are willing to share
happy to, it's something I worked on a bit and seemed OK, but I've been away on holiday and just back so not tested thoroughly. AFK right now but will get a snippet together later