-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(tooltip): trigger with "focus" by default to enhance a11y (#3028)
Fixes #3022
- Loading branch information
1 parent
4c625fc
commit be84733
Showing
10 changed files
with
88 additions
and
6 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
16 changes: 16 additions & 0 deletions
16
e2e-app/src/app/tooltip/focus/tooltip-focus.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,16 @@ | ||
<h3> | ||
Tooltip focus tests | ||
<span class="ml-1 badge {{d1.isOpen() ? 'badge-success' : 'badge-danger'}}" id="open-status">{{d1.isOpen() ? 'open' : 'closed'}}</span> | ||
</h3> | ||
<form id="default"> | ||
<div class="d-flex"> | ||
<div class="flex-row"> | ||
<button id="btn-before" type="button" class="btn btn-outline-secondary ml-2">Button Before</button> | ||
<button #d1="ngbTooltip" ngbTooltip="Tooltip Content" id="btn-tooltip" type="button" | ||
container="body" triggers="focus" class="btn btn-outline-secondary ml-2"> | ||
Tooltip | ||
</button> | ||
<button id="btn-after" type="button" class="btn btn-outline-secondary ml-2">Button After</button> | ||
</div> | ||
</div> | ||
</form> |
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,5 @@ | ||
import {Component} from '@angular/core'; | ||
|
||
@Component({templateUrl: './tooltip-focus.component.html'}) | ||
export class TooltipFocusComponent { | ||
} |
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,32 @@ | ||
import {openUrl} from '../../tools.po'; | ||
import {TooltipFocusPage as TooltipFocusPage} from './tooltip-focus.po'; | ||
import {protractor} from 'protractor'; | ||
|
||
describe('Tooltip Focus', () => { | ||
let page: TooltipFocusPage; | ||
|
||
const expectTooltipToBeOpen = async(message: string) => { | ||
expect(await page.getTooltip().isPresent()).toBeTruthy(message); | ||
expect(await page.getOpenStatus().getText()).toBe('open', message); | ||
}; | ||
|
||
const expectTooltipToBeClosed = async(message: string) => { | ||
expect(await page.getTooltip().isPresent()).toBeFalsy(message); | ||
expect(await page.getOpenStatus().getText()).toBe('closed', message); | ||
}; | ||
|
||
beforeAll(() => page = new TooltipFocusPage()); | ||
|
||
beforeEach(async() => await openUrl('tooltip/focus')); | ||
|
||
it(`should work when triggers === 'focus'`, async() => { | ||
// focusin to show | ||
await page.getButton('before').click(); | ||
await page.getButton('before').sendKeys(protractor.Key.TAB); | ||
await expectTooltipToBeOpen(`Tooltip should be visible when tooltip button gains focus`); | ||
|
||
// focusout to hide | ||
await page.getButton('tooltip').sendKeys(protractor.Key.TAB); | ||
await expectTooltipToBeClosed(`Tooltip should not be visible when tooltip button looses focus`); | ||
}); | ||
}); |
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,9 @@ | ||
import {$} from 'protractor'; | ||
|
||
export class TooltipFocusPage { | ||
getTooltip() { return $('ngb-tooltip-window'); } | ||
|
||
getButton(type: string) { return $(`#btn-${type}`); } | ||
|
||
getOpenStatus() { return $('#open-status'); } | ||
} |
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
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