Skip to content

Commit

Permalink
fix(typeahead): navigation buttons don't submit form anymore
Browse files Browse the repository at this point in the history
Closes #693
  • Loading branch information
jnizet authored and pkozlowski-opensource committed Sep 7, 2016
1 parent 9dcd656 commit 79f4597
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
11 changes: 11 additions & 0 deletions src/typeahead/typeahead-window.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,17 @@ describe('ngb-typeahead-window', () => {
expectResults(fixture.nativeElement, ['bar', '+baz']);
expect(fixture.componentInstance.active).toBe('baz');
});

it('should have buttons of type button', () => {
const html = `
<ngb-typeahead-window [results]="results" [term]="term"></ngb-typeahead-window>`;
const fixture = createTestComponent(html);
const buttons = fixture.nativeElement.querySelectorAll('button');
expect(buttons.length).toBeGreaterThan(0);
for (let i = 0; i < buttons.length; i++) {
expect(buttons[i].getAttribute('type')).toBe('button');
}
});
});

});
Expand Down
2 changes: 1 addition & 1 deletion src/typeahead/typeahead-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export interface ResultTemplateContext {
<ngb-highlight [result]="formatter(result)" [term]="term"></ngb-highlight>
</template>
<template ngFor [ngForOf]="results" let-result let-idx="index">
<button class="dropdown-item" [class.active]="idx === activeIdx"
<button type="button" class="dropdown-item" [class.active]="idx === activeIdx"
(mouseenter)="markActive(idx)"
(click)="select(result)">
<template [ngTemplateOutlet]="resultTemplate || rt"
Expand Down

0 comments on commit 79f4597

Please sign in to comment.