diff --git a/src/datepicker/datepicker-navigation.spec.ts b/src/datepicker/datepicker-navigation.spec.ts index de5088829f..b326420562 100644 --- a/src/datepicker/datepicker-navigation.spec.ts +++ b/src/datepicker/datepicker-navigation.spec.ts @@ -92,19 +92,32 @@ describe('ngb-datepicker-navigation', () => { it('should send navigation events', () => { const fixture = createTestComponent(``); - - const links = getNavigationLinks(fixture.nativeElement); + const [previousButton, nextButton] = getNavigationLinks(fixture.nativeElement); spyOn(fixture.componentInstance, 'onNavigate'); // prev - links[0].click(); + previousButton.click(); expect(fixture.componentInstance.onNavigate).toHaveBeenCalledWith(NavigationEvent.PREV); // next - links[1].click(); + nextButton.click(); expect(fixture.componentInstance.onNavigate).toHaveBeenCalledWith(NavigationEvent.NEXT); }); + it('should retain focus on the navigation links after click', () => { + const fixture = + createTestComponent(``); + const [previousButton, nextButton] = getNavigationLinks(fixture.nativeElement); + + // prev + previousButton.click(); + expect(document.activeElement).toBe(previousButton); + + // next + nextButton.click(); + expect(document.activeElement).toBe(nextButton); + }); + it('should have buttons of type button', () => { const fixture = createTestComponent(``); diff --git a/src/datepicker/datepicker-navigation.ts b/src/datepicker/datepicker-navigation.ts index 4d033fe626..8fab4478fb 100644 --- a/src/datepicker/datepicker-navigation.ts +++ b/src/datepicker/datepicker-navigation.ts @@ -10,7 +10,7 @@ import {NgbDatepickerI18n} from './datepicker-i18n'; styleUrls: ['./datepicker-navigation.scss'], template: `
-