# 在 Chrome 中选择文本时，无法从搜索下拉菜单切换到用户菜单

**URL:** <https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917>\
**Category:** Bug\
**Tags:** search, desktop\
**Created:** [2023 年4 月 17 日 08:47 UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917 "2023-04-17T08:47:38Z")\
**Posts on this page:** 1\
**Showing post:** 15

<div class="post-metadata">

作者： ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)\
发布日期： [2023 年4 月 21 日 18:34 UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/15 "2023-04-21T18:34:16Z")

</div>

谢谢，这应该可以通过以下方式修复：

> <https://github.com/discourse/discourse/pull/21202>
>
> Followup to 17ba00c3950eb0a78dd510f3618f8e7be2d448fc. Fix for https://meta.disco…urse.org/t/-/261917
> 
> This fixes a usability issue where the user couldn't switch to the user menu when the search menu was visible and the text in the input was selected.
> 
> Explanation: The \`click\` event is triggered both when clicking and when selecting text. This means that when selecting text in the search input, at the end of the selection event, a click event is triggered. And if that click event happens outside of the search menu (i.e. when you continue dragging outside the input), then the menu would be dismissed. 
> 
> Previously, we fixed this by checked for the presence of a current text selection. But that results in a small side-effect reported in the linked issue on meta. This PR sets a flag during \`mouseDown\` when starting a text selection in the input and then it uses that flag when evaluating whether to trigger \`clickOutside\` or not.

PR 描述中有一个较长的解释，简而言之，我们之前在选择了文本时跳过了搜索菜单的 `clickOutside` 事件。但是我们自动选择了搜索菜单输入文本，所以这切换到了一种不同的技术。

---

_[View the full topic](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917)._
