Skip to content

Commit

Permalink
search on enter
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegZharkov committed Oct 27, 2020
1 parent ea8529d commit a77a337
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions client/src/components/LibraryFolder/SearchField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
<b-form-input
v-model="search"
class="mr-1"
input="updateSearch($event)"
type="search"
id="filterInput"
placeholder="Search"
@keyup.enter="startSeach()"
/>
</b-input-group>
</template>
Expand All @@ -20,13 +20,17 @@ export default {
awaitingSearch: false,
};
},
methods: {
startSeach() {
this.$emit("updateSearch", this.search);
this.awaitingSearch = false;
},
},
watch: {
search: function () {
if (!this.awaitingSearch) {
setTimeout(() => {
this.$emit("updateSearch", this.search);
this.awaitingSearch = false;
this.startSeach();
}, 1000); // 1 sec delay
}
this.awaitingSearch = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<font-awesome-icon icon="home" />
</a>
<div>
<form class="form-inline">
<div class="form-inline">
<SearchField @updateSearch="updateSearch($event)"></SearchField>
<button
v-if="metadata.can_add_library_item"
Expand Down Expand Up @@ -134,7 +134,7 @@
include deleted
</b-form-checkbox>
</div>
</form>
</div>
</div>
</div>
</div>
Expand Down

0 comments on commit a77a337

Please sign in to comment.