Skip to content

Commit

Permalink
feat(core): change Formly internal extensions priority to <=-1 (#3226)
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Mar 13, 2022
1 parent 21905b1 commit 9885067
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion demo/src/app/guides/custom-formly-extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ When registering an extension with the `FormlyModule`, you can provide an additi
This will be used to change the order in which extensions are executed. If you have multiple extensions that change the same properties of a `FormlyFieldConfig`, you can use this to ensure they are executed in the correct order. Extensions with higher `priority` values will be executed later.

If you don't provide a `priority` option, a default value of `1` will be used. <br/>
Formly's own internal extensions have a priority of `-1`.
Formly's own internal extensions have a priority of `<= -1`.

```typescript
FormlyModule.forRoot({
Expand Down
8 changes: 4 additions & 4 deletions src/core/src/lib/core.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ export function defaultFormlyConfig(config: FormlyConfig): ConfigOption {
{ name: 'formly-template', component: FormlyTemplateType },
],
extensions: [
{ name: 'core', extension: new CoreExtension(config), priority: -1 },
{ name: 'field-validation', extension: new FieldValidationExtension(config), priority: -1 },
{ name: 'field-form', extension: new FieldFormExtension(), priority: -1 },
{ name: 'field-expression', extension: new FieldExpressionExtension(), priority: -1 },
{ name: 'core', extension: new CoreExtension(config), priority: -250 },
{ name: 'field-validation', extension: new FieldValidationExtension(config), priority: -200 },
{ name: 'field-form', extension: new FieldFormExtension(), priority: -150 },
{ name: 'field-expression', extension: new FieldExpressionExtension(), priority: -100 },
],
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/src/lib/services/formly.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ export class FormlyConfig {
// flatten extensions object with sorted keys
this.extensions = Object.keys(this.extensionsByPriority)
.map(Number)
.sort()
.sort((a, b) => a - b)
.reduce(
(acc, prio) => ({
...acc,
Expand Down

0 comments on commit 9885067

Please sign in to comment.