-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dropdown - autoclose on outside click option #1022
Comments
Since this project uses Typescript and Typescript supports enums, you all may want to consider changing |
This can be easily achieved by stopping propagation of click events triggered on menu item elements. |
Scratch this - it won't work properly with multiple dropdowns... |
@forrestab enums are not ideal since you would have to expose an enum on a component's instance. In practice to achieve the following:
You would have to have @Input() autoClose: boolean | 'inside' | 'outside'; |
The document click listener currently runs in the zone '(document:click)': 'closeFromOutsideClick($event)' This means each click will trigger an angular change detection. |
@matthiasscudlik you are right, we are planning to change it. The issue is already tracked via #900 |
Closes ng-bootstrap#1022 BREAKING CHANGE: Dropdown menu now requires usage of the new `ngbDropdownMenu` directive. Before: ```html <div ngbDropdown> <button ngbDropdownToggle>Toggle dropdown</button> <div class="dropdown-menu"> <a class="dropdown-item">Action</a> </div> </div> ``` After (notice **ngbDropdownMenu**): ```html <div ngbDropdown> <button ngbDropdownToggle>Toggle dropdown</button> <div ngbDropdownMenu> <a class="dropdown-item">Action</a> </div> </div> ```
Feature request
It would be a useful addition to have another autoClose option:
onOutsideClick
(or another meaningful name), so we can keep the dropdown open as long as we click somewhere inside it.The text was updated successfully, but these errors were encountered: