mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Navigate search results using J/K keys (#24787)
This commit is contained in:
parent
6dc5fe0c83
commit
80d5acc0ce
@ -819,10 +819,10 @@ export default {
|
|||||||
);
|
);
|
||||||
} else if (document.querySelector(".topic-list")) {
|
} else if (document.querySelector(".topic-list")) {
|
||||||
return document.querySelectorAll(".topic-list .topic-list-item");
|
return document.querySelectorAll(".topic-list .topic-list-item");
|
||||||
} else if ((categoriesTopicsList = this.categoriesTopicsList())) {
|
|
||||||
return categoriesTopicsList;
|
|
||||||
} else if (document.querySelector(".search-results")) {
|
} else if (document.querySelector(".search-results")) {
|
||||||
return document.querySelectorAll(".search-results .fps-result");
|
return document.querySelectorAll(".search-results .fps-result");
|
||||||
|
} else if ((categoriesTopicsList = this.categoriesTopicsList())) {
|
||||||
|
return categoriesTopicsList;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -4,11 +4,14 @@ describe "Search", type: :system do
|
|||||||
let(:search_page) { PageObjects::Pages::Search.new }
|
let(:search_page) { PageObjects::Pages::Search.new }
|
||||||
fab!(:topic)
|
fab!(:topic)
|
||||||
fab!(:post) { Fabricate(:post, topic: topic, raw: "This is a test post in a test topic") }
|
fab!(:post) { Fabricate(:post, topic: topic, raw: "This is a test post in a test topic") }
|
||||||
|
fab!(:topic2) { Fabricate(:topic, title: "Another test topic") }
|
||||||
|
fab!(:post2) { Fabricate(:post, topic: topic2, raw: "This is another test post in a test topic") }
|
||||||
|
|
||||||
describe "when using full page search on mobile" do
|
describe "when using full page search on mobile" do
|
||||||
before do
|
before do
|
||||||
SearchIndexer.enable
|
SearchIndexer.enable
|
||||||
SearchIndexer.index(topic, force: true)
|
SearchIndexer.index(topic, force: true)
|
||||||
|
SearchIndexer.index(topic2, force: true)
|
||||||
end
|
end
|
||||||
|
|
||||||
after { SearchIndexer.disable }
|
after { SearchIndexer.disable }
|
||||||
@ -35,6 +38,26 @@ describe "Search", type: :system do
|
|||||||
expect(search_page).to have_no_search_result
|
expect(search_page).to have_no_search_result
|
||||||
expect(search_page.heading_text).to eq("Search")
|
expect(search_page.heading_text).to eq("Search")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "navigates search results using J/K keys" do
|
||||||
|
visit("/search")
|
||||||
|
|
||||||
|
search_page.type_in_search("test")
|
||||||
|
search_page.click_search_button
|
||||||
|
|
||||||
|
expect(search_page).to have_search_result
|
||||||
|
|
||||||
|
results = all(".fps-result")
|
||||||
|
|
||||||
|
page.send_keys("j")
|
||||||
|
expect(results.first["class"]).to include("selected")
|
||||||
|
|
||||||
|
page.send_keys("j")
|
||||||
|
expect(results.last["class"]).to include("selected")
|
||||||
|
|
||||||
|
page.send_keys("k")
|
||||||
|
expect(results.first["class"]).to include("selected")
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when using full page search on desktop" do
|
describe "when using full page search on desktop" do
|
||||||
|
Loading…
Reference in New Issue
Block a user