From 0227151ef12b1e2e5c9e88fa2e72a6525cd6b27f Mon Sep 17 00:00:00 2001 From: wnvko Date: Fri, 11 May 2018 16:15:38 +0300 Subject: [PATCH 1/2] fix(igxDropDown): fox home and end navigation, closes #984 --- demos/app/drop-down/sample.component.ts | 7 +++++++ src/drop-down/drop-down.component.spec.ts | 4 ---- src/drop-down/drop-down.component.ts | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/demos/app/drop-down/sample.component.ts b/demos/app/drop-down/sample.component.ts index b4a8a13a99f..4031302537d 100644 --- a/demos/app/drop-down/sample.component.ts +++ b/demos/app/drop-down/sample.component.ts @@ -99,6 +99,13 @@ export class DropDownSampleComponent implements OnInit { } this.items.push(item); } + + this.items = [ + { field: "Nav1" }, + { field: "Nav2" }, + { field: "Nav3" }, + { field: "Nav4" } + ]; } constructor() { diff --git a/src/drop-down/drop-down.component.spec.ts b/src/drop-down/drop-down.component.spec.ts index 329f853ac0b..f90b314c591 100644 --- a/src/drop-down/drop-down.component.spec.ts +++ b/src/drop-down/drop-down.component.spec.ts @@ -473,14 +473,10 @@ describe("IgxDropDown ", () => { fixture.whenStable().then(() => { fixture.detectChanges(); const currentItem = fixture.debugElement.queryAll(By.css(".igx-drop-down__item"))[0]; - // tslint:disable-next-line:no-debugger - debugger; currentItem.triggerEventHandler("keydown.ArrowDown", jasmine.createSpyObj("mockEvt", ["stopPropagation", "preventDefault"])); return fixture.whenStable(); }).then(() => { fixture.detectChanges(); - // tslint:disable-next-line:no-debugger - debugger; expect(list.items[3].isFocused).toBeTruthy(); const currentItem = fixture.debugElement.queryAll(By.css(".igx-drop-down__item"))[0]; currentItem.triggerEventHandler("keydown.ArrowUp", jasmine.createSpyObj("mockEvt", ["stopPropagation", "preventDefault"])); diff --git a/src/drop-down/drop-down.component.ts b/src/drop-down/drop-down.component.ts index 9040649aea1..32bb78d97a3 100644 --- a/src/drop-down/drop-down.component.ts +++ b/src/drop-down/drop-down.component.ts @@ -248,7 +248,7 @@ export class IgxDropDownComponent implements IToggleView, OnInit { focusLast() { if (this._focusedItem) { - const focusedItemIndex = (this.items.length - 1); + const focusedItemIndex = (this.items.length); const lastItemIndex = this.getNearestSiblingFocusableItemIndex(focusedItemIndex, Direction.Up); if (lastItemIndex !== -1) { this.changeFocusedItem(this.items[lastItemIndex], this._focusedItem); @@ -293,7 +293,7 @@ export class IgxDropDownComponent implements IToggleView, OnInit { if (this._focusedItem) { this._focusedItem.isFocused = true; } else if (this.allowItemsFocus) { - const firstItemIndex = this.getNearestSiblingFocusableItemIndex(0, Direction.Down); + const firstItemIndex = this.getNearestSiblingFocusableItemIndex(-1, Direction.Down); if (firstItemIndex !== -1) { this.changeFocusedItem(this.items[firstItemIndex]); } @@ -349,7 +349,7 @@ export class IgxDropDownComponent implements IToggleView, OnInit { } index += direction; - if (index >= 0 && index < this.items.length - 1) { + if (index >= 0 && index < this.items.length) { return index; } else { return -1; From fdcc6d1abd820b6045ceb0caa3a772f456e8b325 Mon Sep 17 00:00:00 2001 From: wnvko Date: Fri, 11 May 2018 16:17:36 +0300 Subject: [PATCH 2/2] chore(igxDropDown): remove simple items from sample --- demos/app/drop-down/sample.component.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/demos/app/drop-down/sample.component.ts b/demos/app/drop-down/sample.component.ts index 4031302537d..867a3535739 100644 --- a/demos/app/drop-down/sample.component.ts +++ b/demos/app/drop-down/sample.component.ts @@ -100,12 +100,12 @@ export class DropDownSampleComponent implements OnInit { this.items.push(item); } - this.items = [ - { field: "Nav1" }, - { field: "Nav2" }, - { field: "Nav3" }, - { field: "Nav4" } - ]; + // this.items = [ + // { field: "Nav1" }, + // { field: "Nav2" }, + // { field: "Nav3" }, + // { field: "Nav4" } + // ]; } constructor() {