Fork me on GitHub
#fulcro
<
2022-11-19
>
Eva O23:11:01

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.

Eva O23:11:13

I will paste them here now. (So sorry.)

Eva O23:11:12

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.

Eva O23:11:47

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?

tony.kay17:11:53

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.

Eva O17:11:19

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.

tony.kay00:11:53

Logging is for debug purposes. So you can tell why it might be behaving a certain way. The end use doesn't see those

tony.kay00:11:04

I should change those to debug level

Eva O23:11:58

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.

tony.kay17:11:51

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

Eva O17:11:58

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.

tony.kay00:11:16

Oh, you mean for a brand new one? I see. Yes an unmodified new instance should probably not do that :face_with_rolling_eyes:

Eva O23:11:06

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)))

tony.kay17:11:02

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

Eva O17:11:04

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.

tony.kay01:11:06

Yes, you are right

tony.kay01:11:17

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).

tony.kay01:11:45

BUT, you are right, there should be an easier way to tell that a new thing is “unmodified”.

tony.kay01:11:19

(and it is possible that I’ve written such a thing and am not at the moment rememerbering it 😄 )

tony.kay01:11:13

I think an unmodified-fields function that is the same as dirty-fields, but doesn’t consider tempids in the mix would do it.

tony.kay01:11:15

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.

Eva O23:11:03

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

tony.kay17:11:24

No worries, it just might take a bit to get to them all

tony.kay01:11:59

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.

Eva O22:11:27

Unfortunately my company owns all my IP so I can't really contribute. I would've loved to help if I could. I think fulcro is a really great library

tony.kay16:11:54

Oh boy…yeah, they often try to pull that. Most are not enforceable, and most companies will let you opt out if you disagree during hiring, but I get it. Sometimes you just miss it or really just want the job 😄