Skip to content

Commit

Permalink
feat(typeahead): set autocomplete, autocapitalize and autocorrect off
Browse files Browse the repository at this point in the history
Fixes #520
Closes #525
  • Loading branch information
jnizet authored and pkozlowski-opensource committed Jul 31, 2016
1 parent d74d7f4 commit 46024c3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/typeahead/typeahead.spec.ts
Expand Up @@ -396,6 +396,23 @@ describe('ngb-typeahead', () => {
})));
});

describe('auto attributes', () => {

it('should have autocomplete, autocapitalize and autocorrect attributes set to off',
async(inject([TestComponentBuilder], (tcb) => {
const html = '<input type="text" [ngbTypeahead]="findObjects" />';

tcb.overrideTemplate(TestComponent, html).createAsync(TestComponent).then((fixture) => {
fixture.detectChanges();
const input = getNativeInput(fixture.nativeElement);

expect(input.getAttribute('autocomplete')).toBe('off');
expect(input.getAttribute('autocapitalize')).toBe('off');
expect(input.getAttribute('autocorrect')).toBe('off');
});
})));
});

});

@Component(
Expand Down
5 changes: 4 additions & 1 deletion src/typeahead/typeahead.ts
Expand Up @@ -44,7 +44,10 @@ const NGB_TYPEAHEAD_VALUE_ACCESSOR = {
'[class.open]': '_windowRef !== null',
'(document:click)': '_closePopup()',
'(input)': 'onChange($event.target.value)',
'(keydown)': '_handleKeyDown($event)'
'(keydown)': '_handleKeyDown($event)',
'autocomplete': 'off',
'autocapitalize': 'off',
'autocorrect': 'off'
},
providers: [NGB_TYPEAHEAD_VALUE_ACCESSOR]
})
Expand Down

0 comments on commit 46024c3

Please sign in to comment.