[new feature] DropdownMenu: add close-on-click-outside prop (#3824)
This commit is contained in:
@@ -11,9 +11,16 @@ export type ClickOutsideMixinConfig = {
|
||||
|
||||
export const ClickOutsideMixin = (config: ClickOutsideMixinConfig) =>
|
||||
Vue.extend({
|
||||
props: {
|
||||
closeOnClickOutside: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
|
||||
data() {
|
||||
const clickOutsideHandler = (event: Event) => {
|
||||
if (!this.$el.contains(event.target as Node)) {
|
||||
if (this.closeOnClickOutside && !this.$el.contains(event.target as Node)) {
|
||||
(this as any)[config.method]();
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user