From 5a152dbc0c7b9d191db255b9ca05f31130168570 Mon Sep 17 00:00:00 2001 From: rr- Date: Sun, 28 Aug 2016 23:08:29 +0200 Subject: [PATCH] client/search: go back to page 1 on query change --- client/js/views/posts_header_view.js | 7 +++---- client/js/views/tags_header_view.js | 1 + client/js/views/users_header_view.js | 1 + 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/js/views/posts_header_view.js b/client/js/views/posts_header_view.js index ddc51722..c0f86ddb 100644 --- a/client/js/views/posts_header_view.js +++ b/client/js/views/posts_header_view.js @@ -115,10 +115,9 @@ class PostsHeaderView extends events.EventTarget { if (this._masstagAutoCompleteControl) { this._masstagAutoCompleteControl.hide(); } - let parameters = { - query: this._queryInputNode.value, - page: this._ctx.parameters.page, - }; + let parameters = {query: this._queryInputNode.value}; + parameters.page = parameters.query === this._ctx.parameters.query ? + this._ctx.parameters.page : 1; if (this._massTagInputNode) { parameters.tag = this._massTagInputNode.value; this._massTagInputNode.blur(); diff --git a/client/js/views/tags_header_view.js b/client/js/views/tags_header_view.js index a395d4f0..cb0489e8 100644 --- a/client/js/views/tags_header_view.js +++ b/client/js/views/tags_header_view.js @@ -38,6 +38,7 @@ class TagsHeaderView extends events.EventTarget { this._queryInputNode.blur(); this.dispatchEvent(new CustomEvent('navigate', {detail: {parameters: { query: this._queryInputNode.value, + page: 1, }}})); } } diff --git a/client/js/views/users_header_view.js b/client/js/views/users_header_view.js index 21ba1f1e..e4f1c149 100644 --- a/client/js/views/users_header_view.js +++ b/client/js/views/users_header_view.js @@ -31,6 +31,7 @@ class UsersHeaderView extends events.EventTarget { e.preventDefault(); this.dispatchEvent(new CustomEvent('navigate', {detail: {parameters: { query: this._queryInputNode.value, + page: 1, }}})); } }