Skip to content
This repository was archived by the owner on Dec 30, 2022. It is now read-only.

Commit c58980b

Browse files
committed
fix(input): better mobile experience
1 parent d049d62 commit c58980b

File tree

1 file changed

+46
-31
lines changed
  • packages/vue-instantsearch-input/src

1 file changed

+46
-31
lines changed
Lines changed: 46 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
11
<template>
2-
<input type="search"
3-
autocorrect="off"
4-
autocapitalize="off"
5-
autocomplete="off"
6-
spellcheck="false"
7-
:class="bem()"
8-
v-model="query"
9-
>
2+
<form role="search" action="" @submit.prevent="onFormSubmit">
3+
<input type="search"
4+
autocorrect="off"
5+
autocapitalize="off"
6+
autocomplete="off"
7+
spellcheck="false"
8+
:class="bem()"
9+
v-model="query"
10+
ref="input"
11+
:placeholder="placeholder"
12+
>
13+
</form>
1014
</template>
1115

1216
<script>
13-
import algoliaComponent from 'vue-instantsearch-component'
17+
import algoliaComponent from 'vue-instantsearch-component';
1418
15-
export default {
16-
mixins: [algoliaComponent],
17-
data () {
18-
return {
19-
blockClassName: 'ais-input'
20-
}
21-
},
22-
computed: {
23-
query: {
24-
get () {
25-
return this.searchStore.query
26-
},
27-
set (value) {
28-
this.searchStore.stop()
29-
this.searchStore.query = value
30-
this.$emit('query', value)
19+
export default {
20+
mixins: [algoliaComponent],
21+
props: {
22+
placeholder: {
23+
type: String,
24+
default: ''
25+
}
26+
},
27+
data() {
28+
return {
29+
blockClassName: 'ais-input'
30+
};
31+
},
32+
computed: {
33+
query: {
34+
get() {
35+
return this.searchStore.query;
36+
},
37+
set(value) {
38+
this.searchStore.stop();
39+
this.searchStore.query = value;
40+
this.$emit('query', value);
3141
32-
// We here ensure we give the time to listeners to alter the store's state
33-
// without triggering in between ghost queries.
34-
this.$nextTick(function () {
35-
this.searchStore.start()
36-
})
37-
}
42+
// We here ensure we give the time to listeners to alter the store's state
43+
// without triggering in between ghost queries.
44+
this.$nextTick(function() {
45+
this.searchStore.start();
46+
});
3847
}
3948
}
49+
},
50+
methods: {
51+
onFormSubmit() {
52+
this.$refs.input.blur();
53+
}
4054
}
55+
};
4156
</script>

0 commit comments

Comments
 (0)