Skip to content

Commit

Permalink
feat(typeahead): add input reflecting the 'autocomplete' attribute
Browse files Browse the repository at this point in the history
Fixes #2194
Closes #2366
  • Loading branch information
divdavem authored and pkozlowski-opensource committed May 18, 2018
1 parent 86d2f2d commit 3a7ca58
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/typeahead/typeahead.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,14 @@ describe('ngb-typeahead', () => {
expect(input.getAttribute('autocapitalize')).toBe('off');
expect(input.getAttribute('autocorrect')).toBe('off');
});

it('should have configurable autocomplete attribute', () => {
const fixture =
createTestComponent('<input type="text" [ngbTypeahead]="findObjects" autocomplete="ignored-123456"/>');
const input = getNativeInput(fixture.nativeElement);

expect(input.getAttribute('autocomplete')).toBe('ignored-123456');
});
});

describe('accessibility', () => {
Expand Down
8 changes: 7 additions & 1 deletion src/typeahead/typeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ let nextWindowId = 0;
'[class.open]': 'isPopupOpen()',
'(document:click)': 'onDocumentClick($event)',
'(keydown)': 'handleKeyDown($event)',
'autocomplete': 'off',
'[autocomplete]': 'autocomplete',
'autocapitalize': 'off',
'autocorrect': 'off',
'role': 'combobox',
Expand All @@ -89,6 +89,12 @@ export class NgbTypeahead implements ControlValueAccessor,
private _windowRef: ComponentRef<NgbTypeaheadWindow>;
private _zoneSubscription: any;

/**
* Value for the configurable autocomplete attribute.
* Defaults to 'off' to disable the native browser autocomplete, but this standard value does not seem
* to be always correctly taken into account.
*/
@Input() autocomplete = 'off';

/**
* A selector specifying the element the tooltip should be appended to.
Expand Down

0 comments on commit 3a7ca58

Please sign in to comment.