diff --git a/src/components/Dropdown.vue b/src/components/Dropdown.vue index d658cb72f7df541516c86220855f4c620e50d6bc..0fa9ba3d802b323bae63aa1286874cd830e7a27e 100644 --- a/src/components/Dropdown.vue +++ b/src/components/Dropdown.vue @@ -125,11 +125,10 @@ export default { methods: { toggleDropdown(val) { - if (this.isOpen) { - this.input = ''; // * clear input field when closing dropdown - } else if (this.search) { - //* focus on input if is a search dropdown - this.$refs.input.focus({ + if (this.isOpen) { //* if dropdown is open : + this.input = ''; // * -> clear input field when closing dropdown + } else if (this.search) { //* if dropdown is closed is a search dropdown: + this.$refs.input.focus({ //* -> focus on input field preventScroll: true, }); } else if (this.clearable && val.target && this.selected) { @@ -172,8 +171,9 @@ export default { }, clickOutsideDropdown(e) { - if (!e.target.closest(`#custom-dropdown${this.identifier}`)) + if (!e.target.closest(`#custom-dropdown${this.identifier}`) && this.isOpen) { this.toggleDropdown(false); + } }, }, };