Skip to content

Commit

Permalink
fix: prevent blur when click on children
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernest committed Jun 14, 2021
1 parent b74f3a2 commit 58ab2bf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
:class="[`direction-${direction}`]"
:tabindex="isFocusing ? -1 : tabindex"
@focus="focus"
@blur="() => (searchable ? false : blur())"
@blur="e => (searchable ? false : blur(e))"
v-bind="dataAttrs"
@keypress.enter.exact="
() => highlightedOriginalIndex !== null && addOrRemoveOption($event, optionsWithInfo[highlightedOriginalIndex])
Expand Down Expand Up @@ -331,7 +331,13 @@ const VueSelect = {
if (props.disabled) return
isFocusing.value = true
}
const blur = () => {
const blur = e => {
if (wrapper.value.contains(e?.relatedTarget)) {
setTimeout(() => {
wrapper.value.focus()
})
return
}
isFocusing.value = false
}
const toggle = () => {
Expand Down

0 comments on commit 58ab2bf

Please sign in to comment.