mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-28 03:34:27 +08:00
Meta: https://meta.discourse.org/t/cant-erase-the-bookmark-search-input/357861/4 > When we fill in the bookmark search input and send the request, then we can’t delete the input’s content. After removing the last character, the `searchTerm` getter is called. At this point, `_searchTerm` is empty. However, `this._searchTerm || this.q` will treat the empty string as _falsy_, and the `q` value is displayed instead. It makes it impossible to clear the input. To fix this, we check specifically on the initial state of `_searchTerm,` which is _undefined_, to include an empty string as a valid value. Note: because of `@computed`, the issue is not triggered when the content is selected and deleted.
54 lines
1.1 KiB
Ruby
Vendored
54 lines
1.1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
module PageObjects
|
|
module Pages
|
|
class UserActivityBookmarks < PageObjects::Pages::Base
|
|
def visit(user, q: nil)
|
|
url = "/u/#{user.username_lower}/activity/bookmarks"
|
|
url += "?q=#{q}" if q
|
|
page.visit(url)
|
|
self
|
|
end
|
|
|
|
def search_for(query)
|
|
fill_in_search(query).submit_button.click
|
|
self
|
|
end
|
|
|
|
def clear_query
|
|
fill_in_search("").submit_button.click
|
|
self
|
|
end
|
|
|
|
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)
|
|
self
|
|
end
|
|
|
|
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)
|
|
end
|
|
|
|
def has_no_topic?(topic)
|
|
has_no_content?(topic.title)
|
|
end
|
|
|
|
def submit_button
|
|
@submit_button ||= page.find(".bookmark-search-form button")
|
|
end
|
|
end
|
|
end
|
|
end
|