Skip to content

Commit 4bd8cc8

Browse files
committed
Adjustments based on discussion with component owner
- Moved the single class up to the root .v-select tag - Added a searching class when there is text in the search input - Added clearing of search text on single when clear on select is set to true, otherwise dim the search text (for single, where clear on select is false)
1 parent 536606e commit 4bd8cc8

File tree

1 file changed

+29
-10
lines changed

1 file changed

+29
-10
lines changed

src/components/Select.vue

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -115,13 +115,17 @@
115115
float: left;
116116
line-height: 24px;
117117
}
118-
.v-select .selected-tag.single {
118+
.v-select.single .selected-tag {
119119
background-color: transparent;
120120
border-color: transparent;
121121
}
122-
.v-select.open .selected-tag.single {
122+
.v-select.single.open .selected-tag {
123123
position: absolute;
124-
opacity: 0.5;
124+
opacity: .5;
125+
}
126+
.v-select.single.open.searching .selected-tag,
127+
.v-select.single.loading .selected-tag {
128+
display: none;
125129
}
126130
.v-select .selected-tag .close {
127131
float: none;
@@ -139,6 +143,9 @@
139143
filter: alpha(opacity=20);
140144
opacity: .2;
141145
}
146+
.v-select.single.searching:not(.open):not(.loading) input[type="search"] {
147+
opacity: .2;
148+
}
142149
/* Search Input */
143150
.v-select input[type="search"]::-webkit-search-decoration,
144151
.v-select input[type="search"]::-webkit-search-cancel-button,
@@ -262,7 +269,7 @@
262269
<div class="dropdown v-select" :class="dropdownClasses">
263270
<div ref="toggle" @mousedown.prevent="toggleDropdown" class="dropdown-toggle">
264271

265-
<span class="selected-tag" :class="selectedTagClasses" v-for="option in valueAsArray" v-bind:key="option.index">
272+
<span class="selected-tag" v-for="option in valueAsArray" v-bind:key="option.index">
266273
{{ getOptionLabel(option) }}
267274
<button v-if="multiple" @click="deselect(option)" type="button" class="close">
268275
<span aria-hidden="true">&times;</span>
@@ -702,6 +709,9 @@
702709
* @return {void}
703710
*/
704711
onSearchBlur() {
712+
if (this.clearSearchOnBlur) {
713+
this.search = ''
714+
}
705715
this.open = false
706716
this.$emit('search:blur')
707717
},
@@ -771,20 +781,29 @@
771781
dropdownClasses() {
772782
return {
773783
open: this.dropdownOpen,
784+
single: !this.multiple,
785+
searching: this.searching,
774786
searchable: this.searchable,
775787
unsearchable: !this.searchable,
776788
loading: this.mutableLoading
777789
}
778790
},
779791
780792
/**
781-
* Classes to be output on .selected-tag
782-
* @return {Object}
793+
* If search text should clear on blur
794+
* @return {Boolean} True when single and clearSearchOnSelect
783795
*/
784-
selectedTagClasses() {
785-
return {
786-
single: !this.multiple
787-
}
796+
clearSearchOnBlur() {
797+
return this.clearSearchOnSelect && !this.multiple
798+
},
799+
800+
/**
801+
* Return the current state of the
802+
* search input
803+
* @return {Boolean} True if non empty value
804+
*/
805+
searching() {
806+
return !!this.search
788807
},
789808
790809
/**

0 commit comments

Comments
 (0)