Skip to content

Commit

Permalink
change states
Browse files Browse the repository at this point in the history
  • Loading branch information
josephinoo committed Dec 10, 2024
1 parent 91a0991 commit 1778ab6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/KDropdownMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@
this.lastFocusElement.focus();
}
}
this.$parent.$emit('menu-closed');
window.removeEventListener('keyup', this.handleKeyUp, true);
},
getNextFocusableSibling(focusedElement) {
Expand Down
11 changes: 4 additions & 7 deletions lib/buttons-and-links/KButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,12 @@
},
},
mounted() {
document.addEventListener('click', this.handleClickOutside);
this.$on('menu-closed', () => {
this.isMenuExpanded = false;
});
},
beforeDestroy() {
document.removeEventListener('click', this.handleClickOutside);
this.$off('menu-closed');
},
methods: {
handleClick(event) {
Expand Down Expand Up @@ -195,11 +197,6 @@
this.$el.blur();
}
},
handleClickOutside(event) {
if (!this.$refs.button.contains(event.target)) {
this.isMenuExpanded = false;
}
},
},
};
Expand Down

0 comments on commit 1778ab6

Please sign in to comment.