Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

IE 11 drop down key up and down events issue #1535 #1652

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
3f4222e
Resolving Card action bar still visable after hiding with *ngIf #1421
blackbaud-conorwright Mar 7, 2018
a450054
Addressed PR style comments
blackbaud-conorwright Mar 8, 2018
4b809aa
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 9, 2018
d55f351
Merge branch 'master' into master
Blackbaud-SteveBrush Mar 9, 2018
833bcc7
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 12, 2018
b553659
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 15, 2018
ab82ba3
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 19, 2018
db21c76
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 27, 2018
a282a86
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Mar 30, 2018
d210c2b
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 10, 2018
35e789d
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 17, 2018
636c5dd
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright Apr 23, 2018
54f0bde
added support for up and down key events on dropdowns
blackbaud-conorwright Apr 23, 2018
7979252
removed leftover 'fit' tests
blackbaud-conorwright Apr 24, 2018
7882962
moved duplicate logic from up/down tests to function
blackbaud-conorwright Apr 27, 2018
bdc97a6
Merge remote-tracking branch 'upstream/master'
blackbaud-conorwright May 1, 2018
40903c7
Merge remote-tracking branch 'origin/master' into key-up-down-fix-ie11
blackbaud-conorwright May 1, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/modules/dropdown/dropdown-menu.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,12 @@ export class SkyDropdownMenuComponent implements AfterContentInit, OnDestroy {
public onKeyDown(event: KeyboardEvent) {
const key = event.key.toLowerCase();

if (key === 'arrowdown') {
if (key === 'arrowdown' || key === 'down') {
this.focusNextItem();
event.preventDefault();
}

if (key === 'arrowup') {
if (key === 'arrowup' || key === 'up') {
this.focusPreviousItem();
event.preventDefault();
}
Expand Down
126 changes: 76 additions & 50 deletions src/modules/dropdown/dropdown.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,71 @@ describe('Dropdown component', () => {
return (getComputedStyle(elem).visibility !== 'hidden');
}

function verifyArrowKeyNavigation(downKey: string, upKey: string) {
openPopoverWithButtonClick();

const hostElem = getDropdownMenuHostElement();

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: downKey }
});
tick();
fixture.detectChanges();
tick();

verifyActiveMenuItemByIndex(0);
verifyFocusedMenuItemByIndex(0);

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: downKey }
});
tick();
fixture.detectChanges();
tick();

// The second item is disabled, so it should be skipped!
verifyActiveMenuItemByIndex(2);
verifyFocusedMenuItemByIndex(2);

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: upKey }
});
tick();
fixture.detectChanges();
tick();

// The second item is disabled, so it should be skipped!
verifyActiveMenuItemByIndex(0);
verifyFocusedMenuItemByIndex(0);

// Navigation should loop from the last item to the first:
SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: downKey }
});
SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: downKey }
});
SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: downKey }
});
tick();
fixture.detectChanges();
tick();

verifyActiveMenuItemByIndex(0);
verifyFocusedMenuItemByIndex(0);

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: upKey }
});
tick();
fixture.detectChanges();
tick();

verifyActiveMenuItemByIndex(3);
verifyFocusedMenuItemByIndex(3);
}

describe('basic setup', () => {
it('should have a default button type of "select"', () => {
fixture.detectChanges();
Expand Down Expand Up @@ -273,69 +338,30 @@ describe('Dropdown component', () => {
verifyMenuVisibility();
}));

it('should navigate menu items with arrow keys', fakeAsync(() => {
openPopoverWithButtonClick();

const hostElem = getDropdownMenuHostElement();

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowDown' }
});
it('should open menu if down is pressed', fakeAsync(() => {
tick();
fixture.detectChanges();
tick();

verifyActiveMenuItemByIndex(0);
verifyFocusedMenuItemByIndex(0);

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowDown' }
});
tick();
fixture.detectChanges();
tick();
const hostElem = getDropdownHostElement();

// The second item is disabled, so it should be skipped!
verifyActiveMenuItemByIndex(2);
verifyFocusedMenuItemByIndex(2);
verifyMenuVisibility(false);

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowUp' }
keyboardEventInit: { key: 'Down' }
});
tick();
fixture.detectChanges();
tick();

// The second item is disabled, so it should be skipped!
verifyActiveMenuItemByIndex(0);
verifyFocusedMenuItemByIndex(0);

// Navigation should loop from the last item to the first:
SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowDown' }
});
SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowDown' }
});
SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowDown' }
});
tick();
fixture.detectChanges();
tick();

verifyActiveMenuItemByIndex(0);
verifyFocusedMenuItemByIndex(0);
verifyMenuVisibility();
}));

SkyAppTestUtility.fireDomEvent(hostElem, 'keydown', {
keyboardEventInit: { key: 'ArrowUp' }
});
tick();
fixture.detectChanges();
tick();
it('should navigate menu items with arrow keys', fakeAsync(() => {
verifyArrowKeyNavigation('ArrowDown', 'ArrowUp');
}));

verifyActiveMenuItemByIndex(3);
verifyFocusedMenuItemByIndex(3);
it('should navigate menu items with internet explorer arrow keys', fakeAsync(() => {
verifyArrowKeyNavigation('Down', 'Up');
}));

it('should focus the first item if opened with enter key', fakeAsync(() => {
Expand Down
2 changes: 2 additions & 0 deletions src/modules/dropdown/dropdown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class SkyDropdownComponent implements OnInit, OnDestroy {

// Allow the menu to be opened with the arrowdown key
// if it is first opened with the mouse.
case 'down':
case 'arrowdown':
if (!this.isKeyboardActive) {
this.isKeyboardActive = true;
Expand All @@ -153,6 +154,7 @@ export class SkyDropdownComponent implements OnInit, OnDestroy {
this.isKeyboardActive = true;
break;

case 'down':
case 'arrowdown':
this.isKeyboardActive = true;
this.sendMessage(SkyDropdownMessageType.Open);
Expand Down