store icon indicating copy to clipboard operation
store copied to clipboard

@ngxs/form-plugin model and status are empty until first field edit

Open AlgoTrader opened this issue 8 years ago • 7 comments

It is extremely unpleasant thing to have model and status undefined until first edit of any form field.

Angular form send valueChanges/statusChanges when something changed. For a newly initialized form, no valueChanges/statusChanges values sent yet, so all the model in store is completly uninitialized

It can be easyly fixed, in directive initialization there should be value/status form props read and used for state initialization

AlgoTrader avatar Apr 17 '18 14:04 AlgoTrader

@AlgoTrader As you say it shouldn't be hard to fix. Do you think you could have a go at implementing it in a pull request?

leon avatar Apr 18 '18 06:04 leon

The first state update cause two-way form and state synching. First, all data from state (if it exists) are transferred to form. The second, form model, form state and form dirty are transferred back to state.

We cannot do it in reverse order, then state data can be lost. We cannot make it one-way also. The problem is caused with initial model: undefined, in this case model stays undefined untill first field edit. It is very unpleasant if no changes made to a form

AlgoTrader avatar Apr 18 '18 08:04 AlgoTrader

I fixed the integration test

AlgoTrader avatar Apr 18 '18 15:04 AlgoTrader

not sure I am clear on this. I am using this in my app. with form model initialized to an empty object. This is if the user opens the form in 'new' mode. If the user is editing an existing customer object, I initialize the state through a populate action and the form is shown in 'edit' mode.

tsawan avatar Apr 18 '18 17:04 tsawan

sorry, just noticed it's already merged in.

tsawan avatar Apr 18 '18 17:04 tsawan

Shouldn't this have been closed with #309's merge?

(hint: If you use write e.g. fixes #307 in the PR description or one of its commits, Github will auto-close the issue on PR merge. Also works for other keywords)

(loooong overdue edit: It should of course be the ID of the issue, not the PR, in the auto-close example)

LosD avatar Apr 24 '18 11:04 LosD

As I understand the #309 PR is related to this issue. This issue should have been closed.

arturovt avatar Aug 15 '19 04:08 arturovt