diff --git a/lib/KDropdownMenu.vue b/lib/KDropdownMenu.vue index 5a4fd3f6a..dac694309 100644 --- a/lib/KDropdownMenu.vue +++ b/lib/KDropdownMenu.vue @@ -117,6 +117,7 @@ data() { return { trigger: null, + lastFocusElement: null, }; }, watch: { @@ -147,6 +148,7 @@ handleOpen() { this.$nextTick(() => this.$nextTick(() => this.setFocus())); window.addEventListener('keydown', this.handleOpenMenuNavigation, true); + this.lastFocusElement = document.activeElement; }, setFocus() { this.$refs.menu.$el.querySelector('li').focus(); @@ -162,6 +164,11 @@ ) { this.focusOnButton(); } + + if (this.lastFocusElement) { + this.lastFocusElement.focus(); + } + window.removeEventListener('keyup', this.handleKeyUp, true); }, handleOpenMenuNavigation(event) {