Skip to content

Commit

Permalink
chore(dropdown): Implement "End" key logic #984
Browse files Browse the repository at this point in the history
  • Loading branch information
dafo committed Apr 24, 2018
1 parent a6f0d11 commit 203e31b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/drop-down/dropDown.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,27 @@ export class IgxDropDownComponent implements OnInit, AfterViewInit {
}
}

@HostListener("keydown.End", ["$event"])
public onEndKeyDown(event) {
let focusedItemIndex = (this.items.length - 1);
while ((this.items.toArray()[focusedItemIndex]) && ((this.items.toArray()[focusedItemIndex]).isDisabled
|| (this.items.toArray()[focusedItemIndex]).isHeader)) {
focusedItemIndex--;
}
if (focusedItemIndex < this.items.length - 1) {
if (this._focusedItem) {
this._focusedItem.isFocused = false;
}
this._focusedItem = this.items.toArray()[focusedItemIndex];
this._focusedItem.isFocused = true;
}
const rect = this._focusedItem.element.nativeElement.getBoundingClientRect();
const parentRect = this.toggle.element.getBoundingClientRect();
if (parentRect.bottom < rect.bottom) {
this.toggle.element.scrollTop += (rect.bottom - parentRect.bottom);
}
}

ngOnInit() {
this.toggleAction.target = this.toggle;
this.toggleAction.closeOnOutsideClick = true;
Expand Down

0 comments on commit 203e31b

Please sign in to comment.