Zendesk Button Not Updating Correctly on Topic Change Without Page Refresh

Hi, I’m experiencing an issue with the Zendesk plugin’s “View on Zendesk” button behavior. When a ticket already exists in Zendesk, the button displays as “View on Zendesk” correctly. However, if I navigate to a different topic that doesn’t have a corresponding Zendesk ticket, the button still initially shows “View on Zendesk” instead of “Create Zendesk Ticket” Once I refresh the page, the button updates to show the correct “Create Zendesk Ticket” option.

It seems that the button component isn’t re-rendering upon navigation to a new topic. I believe a solution could involve triggering a re-render of this component whenever there is a page change.

Could anyone advise on how best to approach this, or if there’s a way to force the component to update correctly upon navigation? Any insights or suggestions would be appreciated.

Hi there,

I hope you’re doing well! I wanted to follow up and check if there’s been any update regarding this issue. Your insights or guidance would be greatly appreciated.

Thank you in advance!

It may because it’s not detecting the page change. This is likely due to how the frontend framework (probably Ember.js, since Discourse uses it) handles component rendering during navigation.

You can add a listener for route changes, something similar to this:


export default Component.extend({
  router: service(),

  didInsertElement() {
    this._super(...arguments);

    this.router.on('routeDidChange', () => {
      this.refreshZendeskButton();
    });
  },

  willDestroyElement() {
    this._super(...arguments);

    this.router.off('routeDidChange', this.refreshZendeskButton);
  },
});

That may have to be amended since it uses setupComponent():

The check if there is a valid zendesk ticket uses zendesk_id. Maybe it needs an api.onPageChange()?