Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(datepicker): refine focus state checks (#3549)
This adds additional condition to restrict focus in/out to instance of the datepicker by verifyng if focus event target and related targets are descendants of the datepicker element. This removes false results based only on the class name checks, which fail when focus is switched between datepicker instances. Fixes #3494 Co-authored-by: Piotr Błażejewicz (Peter Blazejewicz) <peterblazejewicz@users.noreply.github.com>
- Loading branch information
1 parent
4f61496
commit 035d399
Showing
9 changed files
with
64 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
e2e-app/src/app/datepicker/multiple/datepicker-multiple.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<h3>Datepicker focus tests</h3> | ||
|
||
<form> | ||
<div> | ||
<ngb-datepicker id="dp1" [startDate]="startDate"></ngb-datepicker> | ||
<ngb-datepicker id="dp2" [startDate]="startDate"></ngb-datepicker> | ||
|
||
<span class="ml-3">startDate is | ||
<span id="start-date">{{ startDate | json }}</span> | ||
</span> | ||
|
||
</div> | ||
|
||
</form> |
6 changes: 6 additions & 0 deletions
6
e2e-app/src/app/datepicker/multiple/datepicker-multiple.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({templateUrl: './datepicker-multiple.component.html'}) | ||
export class DatepickerMultipleComponent { | ||
startDate = {year: 2016, month: 8}; | ||
} |
22 changes: 22 additions & 0 deletions
22
e2e-app/src/app/datepicker/multiple/datepicker-multiple.e2e-spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import {Key} from 'protractor'; | ||
import {sendKey, openUrl} from '../../tools.po'; | ||
import {DatepickerMultiplePage} from './datepicker-multiple.po'; | ||
|
||
describe('Datepicker multiple instances', () => { | ||
let page: DatepickerMultiplePage; | ||
|
||
beforeAll(() => page = new DatepickerMultiplePage()); | ||
|
||
beforeEach(async() => await openUrl('datepicker/multiple')); | ||
|
||
it('the instance tapped should gain focus', async() => { | ||
const dp1 = await page.getDatepicker('#dp1'); | ||
const dp2 = await page.getDatepicker('#dp2'); | ||
await page.getDayElement(new Date(2016, 7, 1), dp1).click(); | ||
await sendKey(Key.ARROW_DOWN); | ||
await page.expectActive(new Date(2016, 7, 8), dp1); | ||
await page.getDayElement(new Date(2016, 7, 1), dp2).click(); | ||
await sendKey(Key.ARROW_DOWN); | ||
await page.expectActive(new Date(2016, 7, 8), dp2); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
e2e-app/src/app/datepicker/multiple/datepicker-multiple.po.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import {DatepickerPage} from './../datepicker.po'; | ||
import {expectFocused} from '../../tools.po'; | ||
|
||
export class DatepickerMultiplePage extends DatepickerPage { | ||
async expectActive(date: Date, datepicker) { | ||
const dateElement = this.getDayElement(date, datepicker); | ||
expect(await dateElement.$('.active').isPresent()).toBeTruthy(`The date should be active`); | ||
await expectFocused(dateElement, `active date should be focused`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters