# 两个长用户名通知截断主题名称

**URL:** https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950
**Category:** UX
**Created:** [2020年十一月2日 00:46 UTC](https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950 "2020-11-02T00:46:09Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![seanblue](https://avatars.discourse-cdn.com/v4/letter/s/dc4da7/32.png) [@seanblue](https://meta.discourse.org/u/seanblue)
#### Post date: [2020年十一月2日 00:46 UTC](https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950/1 "2020-11-02T00:46:09Z")

</div>

请查看下方的第一条通知。最近两位点赞此帖的用户用户名过长，导致我实际上无法看到主题的名称。这可能不是常见的使用场景，但如果有一个简单的修复方法那就太好了。

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

---

<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: [2020年十一月2日 05:55 UTC](https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950/2 "2020-11-02T05:55:23Z")

</div>

我觉得这里没有简单的解决办法，看起来我们被限制为两行。我们得在这里缩短名称。

也许 @awesomerobot 有想法，但我不认为有什么简单的方法可以解决。

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2020年十一月2日 18:54 UTC](https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950/3 "2020-11-02T18:54:25Z")

</div>

我想我可以限制出现在主题标题之前的通知长度，但这需要防止其换行……这应该没问题，因为它似乎很少换行。如果是这样，我认为上面的示例会看起来像这样：

❤ `2OC3aOdKhwSGlxfz, DaHackerKnownAs...`  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; `这是一个非常长的示例标题...`

我不喜欢长用户名会挤掉“和另外 2 人”这部分，但这是一种权衡……

我也可以考虑将用户名包裹在独立的 span 中，以便单独限制它们的长度，这样能更好地保留“和 X 人”的部分……

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [2020年十一月7日 02:20 UTC](https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950/5 "2020-11-07T02:20:50Z")

</div>

我准备了一个能改善现状的 PR：

> <https://github.com/discourse/discourse/pull/11153>
>
> This solves this issue where multiple long usernames force the topic title out o…f the notification (https://meta.discourse.org/t/notification-with-two-long-usernames-cuts-off-topic-name/168950): 
> 
> The problem:
> 
> \<img width="344" alt="Screen Shot 2020-11-06 at 4 57 26 PM" src="https://user-images.githubusercontent.com/1681963/98419210-8ecae200-2052-11eb-94e6-c04e1a1b12bd.png"\>
> 
> The solution:
> 
> \<img width="364" alt="Screen Shot 2020-11-06 at 4 57 44 PM" src="https://user-images.githubusercontent.com/1681963/98419230-9c806780-2052-11eb-9683-05752c5f0033.png"\>
> 
> This truncates long usernames and favors preserving "and N more" and the topic title. The username section of notifications isn't allowed to expand beyond the first line. 
> 
> \<img width="364" alt="Screen Shot 2020-11-06 at 4 50 02 PM" src="https://user-images.githubusercontent.com/1681963/98419266-b326be80-2052-11eb-8e16-09b8b511f8c2.png"\>
> 
> Long titles will still truncate as well:
> 
> \<img width="356" alt="Screen Shot 2020-11-06 at 5 09 05 PM" src="https://user-images.githubusercontent.com/1681963/98419328-d487aa80-2052-11eb-98a9-712ea926dd2c.png"\>

 ![image](https://global.discourse-cdn.com/meta/original/3X/3/a/3a774ce4033bc870b79dbce3122458dfb818ed53.png)
