Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expressionProperties function returning object does not update in Formly 6 #3068

Closed
mikejpeters opened this issue Dec 1, 2021 · 3 comments · Fixed by #3071
Closed

expressionProperties function returning object does not update in Formly 6 #3068

mikejpeters opened this issue Dec 1, 2021 · 3 comments · Fixed by #3071
Labels

Comments

@mikejpeters
Copy link

mikejpeters commented Dec 1, 2021

Description

In Formly 6 when setting a template option to an object using an expressionProperties function,
the value does not update in the field.

e.g. when accessing to.json from the field component it will always be the initial value "none", even when model.input1 has a value:

  expressionProperties: {
    'templateOptions.json': (model) => {
      return { foo: model.input1 ?? 'none' };
    },
  },

This works fine when returning a string or number instead of an object.
Is returning an object supported (it seems to work in Formly 5)?

Minimal Reproduction

Here is an example of it working the way I'd expect in Formly 5:
https://stackblitz.com/edit/angular-formly-5-expressions?file=src/app/app.component.ts

This same example should fail when run on Formly 6.0.0-next.1 and 6.0.0-next.4
(I tried to create a stackblitz using Angular 13 and Formly 6 but kept getting errors, is there a starter I can use?)

Your Environment

  • Angular version: 13.0.2
  • Formly version: 6.0.0-next.4

Additional context

I tested this on 6.0.0-next.1 and 6.0.0-next.4 and in both cases the value doesn't update.

When I log the template option from the field component using ngDoCheck() it looks like this:

{}
  foo: (...)
  get foo: () => state.value
  set foo: currentValue => {…}
  [[Prototype]]: Object

and if I click on it the getter always evaluates to the initial value I set (e.g. "test")

@mikejpeters mikejpeters added the bug label Dec 1, 2021
@mikejpeters mikejpeters changed the title expressionProperties function returning object does not update in Formly 6 expressionProperties function returning object does not update in Formly 6 Dec 1, 2021
@aitboudad
Copy link
Member

(I tried to create a stackblitz using Angular 13 and Formly 6 but kept getting errors, is there a starter I can use?)

its ok as stackblitz doesn't support Angular 13 yet

@aitboudad
Copy link
Member

This issue has been fixed and released as part of v6.0.0-next.5 release.

Please let us know, in case you are still encountering a similar issue/problem.
Thank you!

@markwhitfeld
Copy link

FYI, StackBlitz now supports Angular 13:

Great news! Support for Angular 13 has finally rolled out.
...
For the next day or two (until 12 December 2021), there is a possibility of an initial slow down in starting up the dev server or running NGCC (or potentially even timeouts) as the packages repopulate into the cache as they are used, but it should come right after a refresh or two if you do have any issues. Anything else should be reported as a new issue.

Related StackBlitz issue comment: stackblitz/core#1657 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

3 participants