Editing topic title/category or tag does not re-render docked header

@eviltrout I want to fix this but not sure about what the right way is to route the event.

Repro:

  • Edit first post
  • Scroll down so title,category and tags are now in the header
  • Edit category, tags or title
  • Edit is not reflected in header-topic-info widget cause a reload of topic is not reflected

I can think of some hacks to fix this but not sure what the correct approach is:

  • Option 1: have the header widget observe the category for relevant changes and rerender self. (downside, more observers and need to be careful about unobserving)

  • Option 2: have the controller tell the widget to re-render when first post is edited unconditionally. (downside, no clear API for how to seek out the widget and rerender)

2 Likes

I vote for not observing, that is a path of suffering.

2 Likes

In cases where components don’t exist in a hierarchy (for example, header and main body) I prefer to use our injected appEvents object to signal things like this. In fact, there is already a header:show-topic event that is triggered when the topic is changed while browsing around. So the fix was just to trigger that after the topic was updated:

https://github.com/discourse/discourse/commit/05e99a68cec550eb3b1aa9703bdca462e74303e7

Over time I learned to loathe observers. They still have some uses in our codebase but if there’s a way I can instead say “okay, signal that something changed”, preferably by action handler, I’ll always do that.

8 Likes