A platform for community discussion. Free, open, simple.
FIX: Bookmark search input can't be cleared with backspace with `?q=` present (#31919)
Arkshinedd0a6bd1888c
diff --git a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.jsindex 8cf8c19f404..cdf63d34fa8 100644--- a/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js+++ b/app/assets/javascripts/discourse/app/controllers/user-activity-bookmarks.js@@ -30,7 +30,7 @@ export default class UserActivityBookmarksController extends Controller {@computed("q")get searchTerm() {- return this._searchTerm || this.q;+ return this._searchTerm !== undefined ? this._searchTerm : this.q;}set searchTerm(value) {diff --git a/spec/system/page_objects/pages/user_activity_bookmarks.rb b/spec/system/page_objects/pages/user_activity_bookmarks.rbindex d2b5daa13f5..603bee10634 100644--- a/spec/system/page_objects/pages/user_activity_bookmarks.rb+++ b/spec/system/page_objects/pages/user_activity_bookmarks.rb@@ -20,11 +20,24 @@ module PageObjectsselfend+ def clear_query_with_backspace+ search_element.value.length.times { search_element.send_keys(:backspace) }+ self+ end+def fill_in_search(query)fill_in("bookmark-search", with: query)selfend+ def search_element+ find_by_id("bookmark-search")+ end++ def has_empty_search?+ search_element.value == ""+ end+def has_topic?(topic)has_content?(topic.title)enddiff --git a/spec/system/user_activity_bookmarks_spec.rb b/spec/system/user_activity_bookmarks_spec.rbindex 21260378d75..d330be7bdcd 100644--- a/spec/system/user_activity_bookmarks_spec.rb+++ b/spec/system/user_activity_bookmarks_spec.rb@@ -58,4 +58,10 @@ describe "User activity bookmarks", type: :system doexpect(user_activity_bookmarks).to have_topic(bookmark_1.bookmarkable.topic)expect(user_activity_bookmarks).to have_topic(bookmark_2.bookmarkable.topic)end++ it "can clear the query with backspace" do+ user_activity_bookmarks.visit(current_user, q: "dog")+ user_activity_bookmarks.clear_query_with_backspace+ expect(user_activity_bookmarks).to have_empty_search+ endend