Skip to content

Commit

Permalink
fix(select): correctly emit focus and blur events
Browse files Browse the repository at this point in the history
  • Loading branch information
qmhc committed Apr 6, 2023
1 parent 078681c commit e9ee8ce
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
16 changes: 12 additions & 4 deletions components/select/select.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
ref="reference"
:class="selectorClass"
tabindex="0"
@focus="handleFocus"
@blur="handleBlur"
@focus="!props.filter && handleFocus($event)"
@blur="!props.filter && handleBlur($event)"
>
<div
v-if="hasPrefix"
Expand Down Expand Up @@ -98,7 +98,11 @@
>
<input
ref="input"
:class="[nh.be('input'), nh.bem('input', 'multiple')]"
:class="[
nh.be('input'),
nh.bem('input', 'multiple'),
currentVisible && nh.bem('input', 'visible')
]"
:disabled="props.disabled"
autocomplete="off"
tabindex="-1"
Expand All @@ -107,6 +111,8 @@
@submit.prevent
@input="handleFilterInput"
@keydown="handleFilterKeyDown"
@focus="handleFocus($event)"
@blur="handleBlur($event)"
/>
<span ref="device" :class="nh.be('device')" aria-hidden="true">
{{ currentFilter }}
Expand All @@ -117,7 +123,7 @@
<template v-if="props.filter">
<input
ref="input"
:class="nh.be('input')"
:class="[nh.be('input'), currentVisible && nh.bem('input', 'visible')]"
:disabled="props.disabled"
:placeholder="
hittingLabel || currentLabels[0] || (props.placeholder ?? locale.placeholder)
Expand All @@ -128,6 +134,8 @@
aria-autocomplete="list"
@submit.prevent
@input="handleFilterInput"
@focus="handleFocus($event)"
@blur="handleBlur($event)"
/>
</template>
<template v-else>
Expand Down
5 changes: 5 additions & 0 deletions style/select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ $select: map.merge(
height: 100%;
padding: 0;
color: inherit;
pointer-events: none;
user-select: auto;
background-color: transparent;
border: 0;
Expand All @@ -116,6 +117,10 @@ $select: map.merge(
min-width: 1px;
}

&--visible {
pointer-events: auto;
}

&::placeholder {
color: get-css-var('input-placeholder-color');
}
Expand Down

0 comments on commit e9ee8ce

Please sign in to comment.