Change 'reply-to-tab' click behaviour (embedded posts top)

Hello,

I am working on a theme component and I would like to change the .reply-to-tab Screenshot 2023-04-10 at 9.38.47 click behaviour on desktop. It would works just like on mobile. So not opening the post above the post but jump to the post.

Now I tried with this and it seems working but I am not sure this is the correct implementation. Could someone check this for me? Thank you :slightly_smiling_face:

import { withPluginApi } from "discourse/lib/plugin-api";
import DiscourseURL from "discourse/lib/url";

export default {
  name: "reply-to-tab",
  
  initialize(container) {
    withPluginApi("0.8.7", (api) => {
      const site = api.container.lookup("site:main");
      const siteSettings = api.container.lookup('site-settings:main');
      if (!site.mobileView && !siteSettings.enable_filtered_replies_view) {
        api.reopenWidget("post-article", {
          toggleReplyAbove(goToPost = "false") {
            const replyPostNumber = this.attrs.reply_to_post_number;
            const topicUrl = this._getTopicUrl();
            if (topicUrl) {
              DiscourseURL.routeTo(`${topicUrl}/${replyPostNumber}`);
            }
            return Promise.resolve();
          }
        });
      }
    });
  },
};

https://github.com/discourse/discourse/blob/14cf8eacf1a679c08ea7df93aff17949d1a9c4df/app/assets/javascripts/discourse/app/widgets/post.js#L800

1 Like