This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-19
Channels
- # aleph (5)
- # announcements (1)
- # babashka (5)
- # beginners (123)
- # biff (9)
- # calva (8)
- # cider (1)
- # clj-on-windows (8)
- # clojure (20)
- # clojure-europe (7)
- # clojure-hungary (3)
- # clojure-norway (1)
- # clojure-sweden (32)
- # clojurescript (2)
- # core-async (2)
- # emacs (6)
- # events (3)
- # fulcro (30)
- # graphql (4)
- # gratitude (3)
- # helix (10)
- # honeysql (7)
- # introduce-yourself (11)
- # kaocha (1)
- # malli (16)
- # matcher-combinators (1)
- # off-topic (7)
- # portal (1)
- # re-frame (12)
- # reagent (3)
- # ring (7)
- # scittle (3)
- # shadow-cljs (1)
- # sql (1)
- # tools-deps (8)
I just realized after creating a bunch of issues that I was supposed to post here instead of making issues on the github repo. Apologies.
I'm really sorry if this is the wrong way to handle this. I should've read the instructions. I will not do it again.
Another thing, this one is more of a question: Why are default and optional fields initially marked as complete when creating a form? I thought form completion was purely a validation thing. Why would we want validation on anything in a form when it is first initialized?
That only happens for one you j just loaded, which presumably should already be valid, and you'd want immediate notification if the loaded data was no longer valid with respect to potentially updated validations.
This also happens when creating a new form. For a new form, I might have required fields that haven't been filled. If I don't set a default value of ""
then logs a lot of errors. If I set the default value, the the form displays my validation message when it's initially shown.
Logging is for debug purposes. So you can tell why it might be behaving a certain way. The end use doesn't see those
Also this may be a bug on my end, but whenever I navigate away from a form that I haven't changed in any way, the confirmation dialog pops up. I would assume that should only happen when the form is actually dirty. My current workaround is to override route-denied.
Yes, but if it is showing confirmation then there is some reason it thinks it's dirty. Turn on firm debug option to see what
I turned on the debug option and the form is showing no change between the original and the current state. I navigate away and the confirm dialog pops up. I think it's because all new forms are considered dirty even when they haven't been touched.
Oh, you mean for a brand new one? I see. Yes an unmodified new instance should probably not do that :face_with_rolling_eyes:
Is there a way to check if a new form with a tempid matches the pristine state? fs/dirty?
will always return true. My workaround is to use:
(defn dirty?
[props]
(fs/dirty? (assoc-in props [::fs/config ::fs/id 1] 1)))
I don't understand what you want here. If it is new then the pristine state is irrelevant, since by definition there isn't an old version
In a new form, the pristine state would be when all the fields are set to ""
or their default values. If a form is in that state, then it's fine to navigate away from it. If the form has changed from that state, then I would consider it dirtied.
In this case I’m not sure what the right answer is. I don’t like having to provide any default behavior for this, because in some cases abandoning a modified new thing is also reasonable. The other problem with it is that it ties the form’s implementation to browsers, which could also turn out to be a bad call. The current “solution” has always bothered me, but I’ve just kicked the can down the road because it wasn’t a big deal for anything I’ve been doing (yet).
BUT, you are right, there should be an easier way to tell that a new thing is “unmodified”.
(and it is possible that I’ve written such a thing and am not at the moment rememerbering it 😄 )
I think an unmodified-fields
function that is the same as dirty-fields
, but doesn’t consider tempids in the mix would do it.
A new option to dirty-fields
that triggers that behavior would probably be a better choice, and just default it so that it doesn’t change current behavior.
Sorry for spamming with so many messages. I've just had a lot of ideas that I've kept to myself. I thought I'd be a better citizen if I pointed out the bugs I found rather than write workarounds just for myself
Also happy for help if you want to contribute solutions. Just ping me and indicate you want to fix something and we can discuss a solution before you code it if you have any doubt about what to do.