From ee255783a2deeaca3209ee990e637bccd4b138e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ciar=C3=A1n=20Ainsworth?= Date: Tue, 2 Jul 2019 09:27:07 +0200 Subject: [PATCH] Pressing return on searchbar to search for artists --- front/src/components/audio/SearchBar.vue | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/front/src/components/audio/SearchBar.vue b/front/src/components/audio/SearchBar.vue index 998a668ec..e0c343fed 100644 --- a/front/src/components/audio/SearchBar.vue +++ b/front/src/components/audio/SearchBar.vue @@ -33,6 +33,18 @@ export default { let albumLabel = this.$pgettext('*/*/*', 'Album') let trackLabel = this.$pgettext('*/*/*/Noun', 'Track') let self = this + var searchQuery; + + jQuery(this.$el).keypress(function(e) { + if(e.which == 13) { + // Cancel any API search request to backend... + jQuery(this.$el).search('cancel query'); + // Go direct to the artist page... + router.push("/library/artists?query=" + searchQuery + "&page=1&paginateBy=25&ordering=name"); + } + }); + + jQuery(this.$el).search({ type: 'category', minCharacters: 3, @@ -41,6 +53,7 @@ export default { }, onSearchQuery (query) { self.$emit('search') + searchQuery = query; }, apiSettings: { beforeXHR: function (xhrObject) {