Skip to content
This repository was archived by the owner on Jan 22, 2018. It is now read-only.

Commit da81af1

Browse files
author
Kamil Kisiela
committed
fix(select): does not collapse on [multiple="false"]
Closes #22
1 parent a051684 commit da81af1

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/types/select/select.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import template from './select.html';
2+
import { ngModelAttrsManipulator } from './../../helpers';
23

34
export default (formlyConfigProvider) => {
45
formlyConfigProvider.setType({
@@ -13,9 +14,6 @@ export default (formlyConfigProvider) => {
1314
disabled: {
1415
bound: 'ng-disabled'
1516
},
16-
multiple: {
17-
bound: 'multiple'
18-
},
1917
onClose: {
2018
bound: 'md-on-close'
2119
},
@@ -36,4 +34,11 @@ export default (formlyConfigProvider) => {
3634
}
3735
})
3836
});
37+
38+
formlyConfigProvider.templateManipulators.preWrapper.push((tpl, options) => {
39+
const to = options.templateOptions || {};
40+
// adds multiple only when:
41+
// templateOptions.multiple equals true
42+
return to.multiple === true ? ngModelAttrsManipulator(tpl, options, 'multiple') : tpl;
43+
});
3944
};

tests/types/select-spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ describe('formlyMaterial - select type', () => {
101101
expect(element.attr('multiple')).toBeDefined();
102102
});
103103

104+
it('should not add multiple directive when does not equal true', () => {
105+
compile({
106+
templateOptions: {
107+
multiple: false
108+
}
109+
});
110+
expect(element.attr('multiple')).toBeUndefined();
111+
});
112+
104113
it('should be able to bind md-on-close', () => {
105114
compile();
106115
expect(element.attr('md-on-close')).toBe(`options.templateOptions['onClose']`);

0 commit comments

Comments
 (0)