Skip to content

Commit 79f4597

Browse files
jnizetpkozlowski-opensource
authored andcommitted
fix(typeahead): navigation buttons don't submit form anymore
Closes #693
1 parent 9dcd656 commit 79f4597

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/typeahead/typeahead-window.spec.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,17 @@ describe('ngb-typeahead-window', () => {
129129
expectResults(fixture.nativeElement, ['bar', '+baz']);
130130
expect(fixture.componentInstance.active).toBe('baz');
131131
});
132+
133+
it('should have buttons of type button', () => {
134+
const html = `
135+
<ngb-typeahead-window [results]="results" [term]="term"></ngb-typeahead-window>`;
136+
const fixture = createTestComponent(html);
137+
const buttons = fixture.nativeElement.querySelectorAll('button');
138+
expect(buttons.length).toBeGreaterThan(0);
139+
for (let i = 0; i < buttons.length; i++) {
140+
expect(buttons[i].getAttribute('type')).toBe('button');
141+
}
142+
});
132143
});
133144

134145
});

src/typeahead/typeahead-window.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface ResultTemplateContext {
2626
<ngb-highlight [result]="formatter(result)" [term]="term"></ngb-highlight>
2727
</template>
2828
<template ngFor [ngForOf]="results" let-result let-idx="index">
29-
<button class="dropdown-item" [class.active]="idx === activeIdx"
29+
<button type="button" class="dropdown-item" [class.active]="idx === activeIdx"
3030
(mouseenter)="markActive(idx)"
3131
(click)="select(result)">
3232
<template [ngTemplateOutlet]="resultTemplate || rt"

0 commit comments

Comments
 (0)