core/common/dropdown-focus-trap.directive.ts
Directive to manage focus trapping and keyboard navigation for ngx-bootstrap dropdowns with container="body".
When a dropdown is appended to the body using container="body", the standard cdkTrapFocus
directive doesn't work because the dropdown content is outside the normal DOM hierarchy where
the directive is applied.
This directive:
container="body" opensSimply apply this directive to the same element that has the dropdown directive:
<div dropdown container="body" c8yDropdownFocusTrap #myDropdown="bs-dropdown">
<button dropdownToggle>Select option</button>
<div *dropdownMenu class="dropdown-menu">
<c8y-list-group role="list">
<c8y-li tabindex="0" role="listitem">Option 1</c8y-li>
<c8y-li tabindex="0" role="listitem">Option 2</c8y-li>
</c8y-list-group>
</div>
</div>See CDK FocusTrap
OnDestroy
| Selector | [c8yDropdownFocusTrap] |
Methods |
constructor()
|
| ngOnDestroy |
ngOnDestroy()
|
|
Returns :
void
|