mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FIX: Incorrect title and chevron when filtering by post number. (#14985)
The widget's state did not reflect the state of the controller.
This commit is contained in:
committed by
GitHub
parent
eb82849ccb
commit
db24c9b94e
@@ -388,8 +388,20 @@ createWidget("post-group-request", {
|
||||
createWidget("post-contents", {
|
||||
buildKey: (attrs) => `post-contents-${attrs.id}`,
|
||||
|
||||
defaultState() {
|
||||
return { expandedFirstPost: false, repliesBelow: [] };
|
||||
defaultState(attrs) {
|
||||
const defaultState = {
|
||||
expandedFirstPost: false,
|
||||
repliesBelow: [],
|
||||
};
|
||||
|
||||
if (this.siteSettings.enable_filtered_replies_view) {
|
||||
const topicController = this.register.lookup("controller:topic");
|
||||
|
||||
defaultState.filteredRepliesShown =
|
||||
topicController.replies_to_post_number === attrs.post_number.toString();
|
||||
}
|
||||
|
||||
return defaultState;
|
||||
},
|
||||
|
||||
buildClasses(attrs) {
|
||||
|
||||
@@ -546,3 +546,28 @@ acceptance("Topic last visit line", function (needs) {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
acceptance("Topic filter replies to post number", function (needs) {
|
||||
needs.settings({
|
||||
enable_filtered_replies_view: true,
|
||||
});
|
||||
|
||||
test("visit topic", async function (assert) {
|
||||
await visit("/t/-/280");
|
||||
|
||||
assert.equal(
|
||||
query("#post_3 .show-replies").title,
|
||||
I18n.t("post.filtered_replies_hint", { count: 3 }),
|
||||
"it displays the right title for filtering by replies"
|
||||
);
|
||||
|
||||
await visit("/");
|
||||
await visit("/t/-/280?replies_to_post_number=3");
|
||||
|
||||
assert.equal(
|
||||
query("#post_3 .show-replies").title,
|
||||
I18n.t("post.view_all_posts"),
|
||||
"it displays the right title when filtered by replies"
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user