Skip to content

Commit

Permalink
fix(core): skip merge wrappers when explicitly set (#2673)
Browse files Browse the repository at this point in the history
fix #2665
  • Loading branch information
aitboudad committed Jan 23, 2021
1 parent ce1be94 commit 13f7f72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/core/src/lib/services/formly.config.spec.ts
Expand Up @@ -114,6 +114,20 @@ describe('FormlyConfig service', () => {
extends: 'custom_input1',
});
});

it('should allow override wrappers', () => {
const config = new FormlyConfig();
config.setType([
{ name: 'input', component: TestComponent, wrappers: ['label'] },
{ name: 'input', wrappers: [] },
]);

expect(config.getType('input')).toEqual({
name: 'input',
component: TestComponent,
wrappers: [],
});
});
});

describe('validators', () => {
Expand Down
6 changes: 1 addition & 5 deletions src/core/src/lib/services/formly.config.ts
Expand Up @@ -72,15 +72,11 @@ export class FormlyConfig {
this.types[options.name] = <TypeOption>{ name: options.name };
}

['component', 'extends', 'defaultOptions'].forEach(prop => {
['component', 'extends', 'defaultOptions', 'wrappers'].forEach(prop => {
if (options.hasOwnProperty(prop)) {
this.types[options.name][prop] = options[prop];
}
});

if (options.wrappers) {
options.wrappers.forEach((wrapper) => this.setTypeWrapper(options.name, wrapper));
}
}
}

Expand Down

0 comments on commit 13f7f72

Please sign in to comment.