Skip to content

Commit

Permalink
fix(core): add Angular 14 compatibility
Browse files Browse the repository at this point in the history
fix #3340
  • Loading branch information
aitboudad committed Jul 11, 2022
1 parent 735b8e5 commit e1b9141
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
8 changes: 4 additions & 4 deletions demo/src/app/shared/stackblitz/stackblitz-writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ export class StackblitzWriter {
},
dependencies: deps,
devDependencies: {
'@angular-devkit/build-angular': '~13.0.0',
'@angular/cli': '~13.0.0',
'@angular/compiler-cli': '~13.0.0',
'@angular-devkit/build-angular': '~14.0.0',
'@angular/cli': '~14.0.0',
'@angular/compiler-cli': '~14.0.0',
'@types/node': '^12.11.1',
typescript: '~4.4.3',
typescript: '~4.7.4',
},
},
null,
Expand Down
2 changes: 1 addition & 1 deletion demo/src/app/shared/stackblitz/stackblitz.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const COPYRIGHT = `Copyright 2021 Formly. All Rights Reserved.
Use of this source code is governed by an MIT-style license that
can be found in the LICENSE file at https://github.com/ngx-formly/ngx-formly/blob/main/LICENSE`;

export const angularVersion = '^13.0.0';
export const angularVersion = '^14.0.0';
export const formlyVersion = 'next';

export const dependencies: { [id: string]: { [id: string]: string } } = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,14 @@ describe('FieldExpressionExtension', () => {
},
});

field.hooks.onInit();
field.hooks.onInit(undefined);
expect(field.props.label).toEqual('test');

field.hooks.onDestroy();
field.hooks.onDestroy(undefined);
stream$.next('test2');
expect(field.props.label).toEqual('test');

field.hooks.onInit();
field.hooks.onInit(undefined);
expect(field.props.label).toEqual('test2');
});

Expand All @@ -432,7 +432,7 @@ describe('FieldExpressionExtension', () => {
},
});

field.hooks.onInit();
field.hooks.onInit(undefined);
expect(field.formControl.value).toEqual('test');
});

Expand Down
2 changes: 1 addition & 1 deletion src/core/src/lib/models/fieldconfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ export interface FormlyFieldProps {
keypress?: FormlyAttributeEvent;
}

export type FormlyHookFn = (field?: FormlyFieldConfig) => void;
export type FormlyHookFn = (field: FormlyFieldConfig) => void;

export interface FormlyHookConfig {
onInit?: FormlyHookFn;
Expand Down
4 changes: 2 additions & 2 deletions src/schematics/utils/lib-versions.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const angularVersion = '^13.0.0';
export const ngxFormlyVersion = '^6.0.0-beta';
export const angularVersion = '^14.0.0';
export const ngxFormlyVersion = '^6.0.0-rc';
5 changes: 3 additions & 2 deletions src/ui/material/form-field/src/field.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,9 @@ export abstract class FieldType<F extends FormlyFieldConfig<FormlyFieldProps>>
this.formField._control = control;

// temporary fix for https://github.com/angular/material2/issues/6728
if (control?.ngControl?.valueAccessor?.hasOwnProperty('_formField')) {
(control.ngControl.valueAccessor as any)['_formField'] = this.formField;
const ngControl = control?.ngControl as any;
if (ngControl?.valueAccessor?.hasOwnProperty('_formField')) {
ngControl.valueAccessor['_formField'] = this.formField;
}

['prefix', 'suffix'].forEach((type) =>
Expand Down

0 comments on commit e1b9141

Please sign in to comment.