Skip to content

Commit f82cfc6

Browse files
authored
Merge pull request #2 from howard-tzw/dev
Fix mobile selection bug
2 parents cb9a9a6 + f45a67b commit f82cfc6

File tree

7 files changed

+58
-39
lines changed

7 files changed

+58
-39
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
44

5+
### [0.0.3](https://github.com/howard-tzw/vue3-select/compare/v0.0.2...v0.0.3) (2023-05-09)
6+
7+
8+
### Bug Fixes
9+
10+
* fix mobile selection bug ([11f34ce](https://github.com/howard-tzw/vue3-select/commit/11f34ce7d5f43e654bbba0bd1791c586f98f21ba))
11+
512
### [0.0.2](https://github.com/howard-tzw/vue3-select/compare/v4.0.0-beta.6...v0.0.2) (2023-05-04)
613

714

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,5 @@
2929
"test",
3030
"tests"
3131
],
32-
"version": "0.0.2"
32+
"version": "0.0.3"
3333
}

dev/Dev.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<div id="app">
3+
<p>searchable</p>
34
<v-select v-model="selected" v-bind="config" />
5+
6+
<p>unsearchable</p>
7+
<v-select v-model="selected" v-bind="config" :searchable="false" />
48
</div>
59
</template>
610

@@ -30,7 +34,8 @@ body {
3034
#app {
3135
height: 100%;
3236
max-width: 20rem;
33-
margin: 10rem auto 0;
37+
margin: 0 auto;
38+
padding: 10px;
3439
}
3540
3641
hr {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vue3-select",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "A maintained fork of vue-select for Vue 3",
55
"author": "Jeff Sagal <[email protected]>, Howard Chen <[email protected]>",
66
"homepage": "https://vue-select.org",

src/components/Select.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,7 @@ export default {
987987
988988
methods: {
989989
clickOutside() {
990-
if (this.open) {
990+
if (this.open && !this.searchable) {
991991
this.open = false
992992
}
993993
},
@@ -1129,11 +1129,12 @@ export default {
11291129
11301130
if (this.open && targetIsNotSearch) {
11311131
this.searchEl.blur()
1132+
} else if (this.open && !targetIsNotSearch && !this.searchable) {
1133+
this.open = false
11321134
} else if (!this.disabled) {
1135+
this.open = true
11331136
this.searchEl.focus()
11341137
}
1135-
1136-
this.open = !this.open
11371138
},
11381139
11391140
/**
@@ -1271,6 +1272,7 @@ export default {
12711272
* @return {void}
12721273
*/
12731274
onSearchBlur() {
1275+
this.open = false
12741276
if (this.mousedown && !this.searching) {
12751277
this.mousedown = false
12761278
} else {
@@ -1294,6 +1296,7 @@ export default {
12941296
* @return {void}
12951297
*/
12961298
onSearchFocus() {
1299+
this.open = true
12971300
this.$emit('search:focus')
12981301
},
12991302

src/css/modules/search-input.css

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,37 +6,41 @@
66
* If it's up here on it's own, it'll hide it.
77
*/
88
.vs__search::-webkit-search-cancel-button {
9-
display: none;
9+
display: none;
1010
}
1111

1212
.vs__search::-webkit-search-decoration,
1313
.vs__search::-webkit-search-results-button,
1414
.vs__search::-webkit-search-results-decoration,
1515
.vs__search::-ms-clear {
16-
display: none;
16+
display: none;
1717
}
1818

1919
.vs__search,
2020
.vs__search:focus {
21-
color: var(--vs-search-input-color);
22-
appearance: none;
23-
line-height: var(--vs-line-height);
24-
font-size: var(--vs-font-size);
25-
border: 1px solid transparent;
26-
border-left: none;
27-
outline: none;
28-
margin: 4px 0 0 0;
29-
padding: 0 7px;
30-
background: none;
31-
box-shadow: none;
32-
width: 0;
33-
max-width: 100%;
34-
flex-grow: 1;
35-
z-index: 1;
21+
/* disable the quick blinking effect when the input has been hit */
22+
/* refer to https://stackoverflow.com/questions/3516173/ipad-safari-how-to-disable-the-quick-blinking-effect-when-a-link-has-been-hit */
23+
-webkit-tap-highlight-color: transparent;
24+
25+
color: var(--vs-search-input-color);
26+
appearance: none;
27+
line-height: var(--vs-line-height);
28+
font-size: var(--vs-font-size);
29+
border: 1px solid transparent;
30+
border-left: none;
31+
outline: none;
32+
margin: 4px 0 0 0;
33+
padding: 0 7px;
34+
background: none;
35+
box-shadow: none;
36+
width: 0;
37+
max-width: 100%;
38+
flex-grow: 1;
39+
z-index: 1;
3640
}
3741

3842
.vs__search::placeholder {
39-
color: var(--vs-search-input-placeholder-color);
43+
color: var(--vs-search-input-placeholder-color);
4044
}
4145

4246
/**
@@ -45,17 +49,17 @@
4549

4650
/* Unsearchable */
4751
.vs--unsearchable {
48-
.vs__search {
49-
opacity: 1;
50-
}
51-
&:not(.vs--disabled) .vs__search {
52-
cursor: pointer;
53-
}
52+
.vs__search {
53+
opacity: 1;
54+
}
55+
&:not(.vs--disabled) .vs__search {
56+
cursor: pointer;
57+
}
5458
}
5559

5660
/* Single, when searching but not loading or open */
5761
.vs--single.vs--searching:not(.vs--open):not(.vs--loading) {
58-
.vs__search {
59-
opacity: 0.2;
60-
}
62+
.vs__search {
63+
opacity: 0.2;
64+
}
6165
}

src/directives/clickOutside.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,17 @@ export default {
77
binding.value(event)
88
}
99
}
10-
const clickHandler =
11-
'ontouchstart' in document.documentElement ? 'touchstart' : 'click'
10+
// const clickHandler =
11+
// 'ontouchstart' in document.documentElement ? 'touchstart' : 'click'
1212
setTimeout(() => {
13-
document.addEventListener(clickHandler, el.clickOutsideEvent)
13+
document.addEventListener('click', el.clickOutsideEvent)
1414
}, 0)
1515
},
1616
unmounted: (el) => {
1717
const clickOutsideEvent = el.clickOutsideEvent
1818
delete el.clickOutsideEvent
19-
const clickHandler =
20-
'ontouchstart' in document.documentElement ? 'touchstart' : 'click'
21-
document.removeEventListener(clickHandler, clickOutsideEvent)
19+
// const clickHandler =
20+
// 'ontouchstart' in document.documentElement ? 'touchstart' : 'click'
21+
document.removeEventListener('click', clickOutsideEvent)
2222
},
2323
}

0 commit comments

Comments
 (0)