From c836d67cac4ff85cf50e41da7b791dd6934c09b1 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 29 Mar 2019 08:53:35 +0800 Subject: [PATCH] UX: Collapse advanced search on mobile when searching. On smaller mobile devices, the height of the advanced search filters takes up the whole real estate that it requires the user to scroll down significantly in order to view the results. --- .../discourse/controllers/full-page-search.js.es6 | 1 + .../acceptance/search-mobile-test.js.es6 | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 index 12f970e42f..9ede0a7346 100644 --- a/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/controllers/full-page-search.js.es6 @@ -315,6 +315,7 @@ export default Ember.Controller.extend({ search() { this.set("page", 1); this._search(); + if (this.site.mobileView) this.set("expanded", false); }, toggleAdvancedSearch() { diff --git a/test/javascripts/acceptance/search-mobile-test.js.es6 b/test/javascripts/acceptance/search-mobile-test.js.es6 index 3f16a6982c..0469eff37c 100644 --- a/test/javascripts/acceptance/search-mobile-test.js.es6 +++ b/test/javascripts/acceptance/search-mobile-test.js.es6 @@ -11,13 +11,26 @@ QUnit.test("search", async assert => { exists("input.full-page-search"), "it shows the full page search form" ); + assert.ok(!exists(".search-results .fps-topic"), "no results by default"); + await click(".search-advanced-title"); + + assert.ok( + find(".search-advanced-filters").length === 1, + "it should expand advanced search filters" + ); + await fillIn(".search-query", "posts"); await click(".search-cta"); assert.ok(find(".fps-topic").length === 1, "has one post"); + assert.ok( + find(".search-advanced-filters").length === 0, + "it should collapse advanced search filters" + ); + await click("#search-button"); assert.equal(