mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 19:02:46 +08:00
FEATURE: enable list keyboard shortcuts on filter route (#27551)
Previously filter route was not setting topic list, this meant that keyboard navigation using "G" "J" was not functioning. This amends it by ensuring the list is set after looking up the model.
This commit is contained in:
parent
982c005979
commit
d29160131d
|
@ -1,3 +1,4 @@
|
||||||
|
import { setTopicList } from "discourse/lib/topic-list-tracker";
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import I18n from "discourse-i18n";
|
import I18n from "discourse-i18n";
|
||||||
|
|
||||||
|
@ -6,11 +7,15 @@ export default class DiscoveryFilterRoute extends DiscourseRoute {
|
||||||
q: { replace: true, refreshModel: true },
|
q: { replace: true, refreshModel: true },
|
||||||
};
|
};
|
||||||
|
|
||||||
model(data) {
|
async model(data) {
|
||||||
return this.store.findFiltered("topicList", {
|
const list = await this.store.findFiltered("topicList", {
|
||||||
filter: "filter",
|
filter: "filter",
|
||||||
params: { q: data.q },
|
params: { q: data.q },
|
||||||
});
|
});
|
||||||
|
|
||||||
|
setTopicList(list);
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
titleToken() {
|
titleToken() {
|
||||||
|
|
|
@ -44,8 +44,16 @@ describe "Filtering topics", type: :system do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "when filtering by status" do
|
describe "when filtering by status" do
|
||||||
fab!(:topic)
|
fab!(:topic) do
|
||||||
fab!(:closed_topic) { Fabricate(:topic, closed: true) }
|
topic = Fabricate(:topic, bumped_at: 1.day.ago)
|
||||||
|
Fabricate(:post, topic: topic)
|
||||||
|
topic
|
||||||
|
end
|
||||||
|
fab!(:closed_topic) do
|
||||||
|
topic = Fabricate(:topic, closed: true)
|
||||||
|
Fabricate(:post, topic: topic)
|
||||||
|
topic
|
||||||
|
end
|
||||||
|
|
||||||
it "should display the right topics when the status filter is used in the query string" do
|
it "should display the right topics when the status filter is used in the query string" do
|
||||||
sign_in(user)
|
sign_in(user)
|
||||||
|
@ -55,6 +63,14 @@ describe "Filtering topics", type: :system do
|
||||||
expect(topic_list).to have_topic(topic)
|
expect(topic_list).to have_topic(topic)
|
||||||
expect(topic_list).to have_topic(closed_topic)
|
expect(topic_list).to have_topic(closed_topic)
|
||||||
|
|
||||||
|
topic_list.visit_topic(closed_topic)
|
||||||
|
expect(page).to have_current_path(closed_topic.url)
|
||||||
|
|
||||||
|
send_keys("gj")
|
||||||
|
|
||||||
|
expect(page).to have_current_path(topic.url)
|
||||||
|
|
||||||
|
visit("/filter")
|
||||||
topic_query_filter.fill_in("status:open")
|
topic_query_filter.fill_in("status:open")
|
||||||
|
|
||||||
expect(topic_list).to have_topic(topic)
|
expect(topic_list).to have_topic(topic)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user