FIX: Give the topic timeline unique keys for state

FIX: Give the topic timeline unique keys for state

We’ve observed an error where the back button is displayed improperly in the topic timeline. It’s unfortunately been hard to reproduce but we suspect it’s related to leftover state when re-rendering.

This fix optimistically tries to fix the error by introducing the topic’s id to the unique key the widgets use for state. We can deploy this and keep an eye out for the bug in the future.

diff --git a/app/assets/javascripts/discourse/app/widgets/topic-timeline.js b/app/assets/javascripts/discourse/app/widgets/topic-timeline.js
index 0314981..85b088f 100644
--- a/app/assets/javascripts/discourse/app/widgets/topic-timeline.js
+++ b/app/assets/javascripts/discourse/app/widgets/topic-timeline.js
@@ -144,7 +144,7 @@ createWidget("timeline-padding", {
 
 createWidget("timeline-scrollarea", {
   tagName: "div.timeline-scrollarea",
-  buildKey: () => `timeline-scrollarea`,
+  buildKey: (attrs) => `timeline-scrollarea-${attrs.topic.id}`,
 
   buildAttributes() {
     return { style: `height: ${scrollareaHeight()}px` };
@@ -411,7 +411,7 @@ createWidget("timeline-footer-controls", {
 export default createWidget("topic-timeline", {
   tagName: "div.topic-timeline",
 
-  buildKey: () => "topic-timeline-area",
+  buildKey: (attrs) => `topic-timeline-area-${attrs.topic.id}`,
 
   defaultState() {
     return { position: null, excerpt: null };

GitHub sha: b246a63a5922321eb63d28a191a0cde3f1152f21

This commit appears in #14305 which was approved by markvanlan. It was merged by eviltrout.