# 如果帖子少于 3 条，在特定浏览器宽度下主题时间线无法打开

**URL:** https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201
**Category:** Bug
**Created:** [2019年七月28日 17:57 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201 "2019-07-28T17:57:26Z")
**Posts on this page:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [2019年七月28日 17:57 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/1 "2019-07-28T17:57:26Z")

</div>

如何复现：

1. 访问 [此页面](https://experts.feverbee.com/t/congrats-on-the-10-years/8333)。
2. 缩小浏览器宽度，直到出现主题进度条：  
 ![image](https://global.discourse-cdn.com/meta/original/3X/7/d/7d82b8bb94bc8ab568eb2bd80662d135317751c9.png)
3. 点击主题进度条 =\> 主题时间线未打开

我认为该问题是由 [这段代码](https://github.com/discourse/discourse/blob/9a17b196365a1f9a5e88a0f8a36e2e35c56b39bc/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6#L495) 引起的。

---

<div class="post-metadata">

### Author: ![justin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/justin/32/157614_2.png) [@justin](https://meta.discourse.org/u/justin)
#### Post date: [2019年七月31日 14:55 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/2 "2019-07-31T14:55:30Z")

</div>

你能在 meta 或 [try.discourse.org](http://try.discourse.org) 上复现这个问题吗？

我可以在 Feverbee 上复现，但在这里不行。如果我们在这里无法复现，那可能是他们所做的定制导致的。

---

<div class="post-metadata">

### Author: ![jack2](https://avatars.discourse-cdn.com/v4/letter/j/ac91a4/32.png) [@jack2](https://meta.discourse.org/u/jack2)
#### Post date: [2019年七月31日 16:37 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/3 "2019-07-31T16:37:40Z")

</div>

你可以在这里复现：

> **[Death by poisonous and electric watermelon](https://try.discourse.org/t/death-by-poisonous-and-electric-watermelon/268)**
>
> The Bradford Watermelon Story - Mind of a Chef:

（缩小宽度，但不要太窄）

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2019年八月1日 02:11 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/4 "2019-08-01T02:11:35Z")

</div>

这确实是一个 bug……如果主题中只有 2 篇帖子，并且你缩小屏幕，就会出现这种情况。

我同意，很可能是链接的代码导致了问题。

鉴于这是种子数据的一部分，链接应保持稳定。

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [2019年八月6日 17:59 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/6 "2019-08-06T17:59:54Z")

</div>

你能看看这个吗 @j.jaffeux？

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2019年八月7日 11:27 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/10 "2019-08-07T11:27:24Z")

</div>

是的，[这段代码负责处理该问题](https://github.com/discourse/discourse/blob/9a17b196365a1f9a5e88a0f8a36e2e35c56b39bc/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6#L495)，它会在窗口高度与主题高度达到特定比例时触发。

但我不理解的是，预期的行为应该是什么？我可以直接移除这个检查让它正常工作，但我猜我们当初添加它是有原因的？

@eviltrout 你实现了这个初始功能 [FIX: If a topic is really long, show the timeline · discourse/discourse@79763a6 · GitHub](https://github.com/discourse/discourse/commit/79763a6b97ae3d6c564f243e59e87b721da1ead4)

这个逻辑现在是否不再适用？公式是否有误？我认为它在主题实际上并不大的情况下也被触发了，所以也许我们应该修复这个问题？

另外，我发现所有“推荐主题”都被用在了这个主题高度计算中：`${"#topic").css("background", "red")}`：

 ![17](https://global.discourse-cdn.com/meta/original/3X/8/e/8e78b12e97e284fb33ba6f71acad20683ef6509b.png)

也许这就是自从你实现该功能以来发生的变化。

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2019年八月7日 11:38 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/11 "2019-08-07T11:38:29Z")

</div>

另外，我们是否应该早点修复这个问题？在这种情况下为什么要显示主题进度？

如果帖子数量 \<= 3，当 posts.height \< window.height \* 1.5 时，是否隐藏主题进度？

---

<div class="post-metadata">

### Author: ![eviltrout](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/eviltrout/32/5275_2.png) [@eviltrout](https://meta.discourse.org/u/eviltrout)
#### Post date: [2019年八月7日 16:52 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/12 "2019-08-07T16:52:54Z")

</div>

最初的设计逻辑是，如果主题内容非常简短，就不显示进度小部件，我认为这仍然合理。

不过，我之前的理解是，这里的 bug 在于小部件确实显示了，但点击它却没有反应。一个合适的修复方案是：只要小部件显示出来，点击功能就应该生效。至于在其他时候（例如主题简短时）将其隐藏，我完全同意这样做。

---

<div class="post-metadata">

### Author: ![sam](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/sam/32/102149_2.png) [@sam](https://meta.discourse.org/u/sam)
#### Post date: [2019年八月7日 21:15 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/13 "2019-08-07T21:15:47Z")

</div>

我在想，我们是否至少应该在移动端/折叠状态下将隐藏阈值改为 1（甚至直接从移动端/折叠状态中移除这个逻辑）。

即使在移动端只有两条帖子，区分第一条和第二条也会很有帮助。

---

<div class="post-metadata">

### Author: ![cvx](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/cvx/32/152146_2.png) [@cvx](https://meta.discourse.org/u/cvx)
#### Post date: [2019年八月7日 22:51 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/14 "2019-08-07T22:51:08Z")

</div>

始终显示时间线在桌面端也有其价值，例如当您正在阅读的帖子无法在一屏内完整显示时。

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年三月29日 09:47 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/15 "2020-03-29T09:47:15Z")

</div>

这应该能解决问题：

> <https://github.com/discourse/discourse/pull/9304>
>
> The streamlength/height code when true would return just after we had inserted t…he timeline-controls, resulting, on topic-progress event to display an empty timeline-controls when clicked.
> 
> I think this code in unecessary and we should only rely on the code in \`hideProgress\` which will currenly hide the progress is the stream has only one post displayed on desktop (always shown on mobile).

详细信息请参阅提交记录。

---

<div class="post-metadata">

### Author: ![j.jaffeux](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/j.jaffeux/32/60297_2.png) [@j.jaffeux](https://meta.discourse.org/u/j.jaffeux)
#### Post date: [2020年四月3日 17:54 UTC](https://meta.discourse.org/t/the-topic-timeline-doesnt-open-in-certain-browser-widths-if-you-have-less-than-3-posts/124201/16 "2020-04-03T17:54:02Z")

</div>

此主题在最后一次回复 5 天后自动关闭。不再允许新回复。
