Skip to content

Commit

Permalink
fix(dropdown): fix keyboard navigation with 'body' container
Browse files Browse the repository at this point in the history
Fixes #3066
  • Loading branch information
maxokorokov committed Mar 28, 2019
1 parent 9e13e7f commit fee06f1
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/dropdown/dropdown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,15 @@ export class NgbDropdownItem {
*/
@Directive({
selector: '[ngbDropdownMenu]',
host: {'[class.dropdown-menu]': 'true', '[class.show]': 'dropdown.isOpen()', '[attr.x-placement]': 'placement'}
host: {
'[class.dropdown-menu]': 'true',
'[class.show]': 'dropdown.isOpen()',
'[attr.x-placement]': 'placement',
'(keydown.ArrowUp)': 'dropdown.onKeyDown($event)',
'(keydown.ArrowDown)': 'dropdown.onKeyDown($event)',
'(keydown.Home)': 'dropdown.onKeyDown($event)',
'(keydown.End)': 'dropdown.onKeyDown($event)'
}
})
export class NgbDropdownMenu {
placement: Placement = 'bottom';
Expand Down Expand Up @@ -92,7 +100,11 @@ export class NgbDropdownAnchor {
'class': 'dropdown-toggle',
'aria-haspopup': 'true',
'[attr.aria-expanded]': 'dropdown.isOpen()',
'(click)': 'toggleOpen()'
'(click)': 'toggleOpen()',
'(keydown.ArrowUp)': 'dropdown.onKeyDown($event)',
'(keydown.ArrowDown)': 'dropdown.onKeyDown($event)',
'(keydown.Home)': 'dropdown.onKeyDown($event)',
'(keydown.End)': 'dropdown.onKeyDown($event)'
},
providers: [{provide: NgbDropdownAnchor, useExisting: forwardRef(() => NgbDropdownToggle)}]
})
Expand All @@ -107,19 +119,8 @@ export class NgbDropdownToggle extends NgbDropdownAnchor {
/**
* Transforms a node into a dropdown.
*/
@Directive({
selector: '[ngbDropdown]',
exportAs: 'ngbDropdown',
host: {
'[class.show]': 'isOpen()',
'(keydown.ArrowUp)': 'onKeyDown($event)',
'(keydown.ArrowDown)': 'onKeyDown($event)',
'(keydown.Home)': 'onKeyDown($event)',
'(keydown.End)': 'onKeyDown($event)'
}
})
export class NgbDropdown implements OnInit,
OnDestroy {
@Directive({selector: '[ngbDropdown]', exportAs: 'ngbDropdown', host: {'[class.show]': 'isOpen()'}})
export class NgbDropdown implements OnInit, OnDestroy {
private _closed$ = new Subject<void>();
private _zoneSubscription: Subscription;
private _bodyContainer: HTMLElement;
Expand Down

1 comment on commit fee06f1

@mendeza
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merci beaucoup, Max!

Please sign in to comment.