# Can't switch from search drop down to user menu when text selected on 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:** [April 17, 2023, 8:47am 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:** 12
**Page:** 1

<div class="post-metadata">

### Author: ![Don](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/don/32/228726_2.png) [@Don](https://meta.discourse.org/u/Don)
#### Post date: [April 17, 2023, 8:47am UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/1 "2023-04-17T08:47:39Z")

</div>

Hello,

I noticed when the drop down search panel contains a selected text can’t switch to the drop down user menu.

It happens mostly when you previously type something in search after it when you open search the input field text will auto selected.

Repro:

![Apr-17-2023 10-45-52](https://global.discourse-cdn.com/meta/original/4X/6/7/f/67f359497afd02a3933c4fe1b648e3999167ce14.gif)

Thank you :slightly_smiling_face:

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 17, 2023, 12:32pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/2 "2023-04-17T12:32:03Z")

</div>

I move this to #Contribute > Bug. Even if it’s a small one and kind of an edge case, it still prevents a regular action from working, even if it can easily be circumvented. :slight_smile:

Good catch :fishing_pole_and_fish:

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 17, 2023, 12:39pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/3 "2023-04-17T12:39:22Z")

</div>

I can’t replicate this. What do I have to do?

- Open search pop-up (on topic list, or in topic)
- Type in ‘hello’
- Close search by clicking outside the box
- Open search, previous ‘hello’ entry still present and autoselected
- Click on avatar

Doing that opens the avatar menu for me?

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 17, 2023, 12:41pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/4 "2023-04-17T12:41:00Z")

</div>

1. Open the search box

2. Type something

3. Select the text

4. Click the avatar → It does nothing when it should be opening the user menu :slight_smile:

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 17, 2023, 12:45pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/5 "2023-04-17T12:45:24Z")

</div>

Hmmm :thinking: This also opens the user menu for me as well.

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [April 17, 2023, 12:46pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/6 "2023-04-17T12:46:57Z")

</div>

i’ve replicated this on desktop. the text has to be selected (highlighted).

i actually noticed this a while back on meta but didn’t think anything of it at the time. the search field retains your last search and often the text is selected by default. if you click the search icon instead of the avatar by mistake, it’s noticeable when you have previous search there that you have to close it before opening the avatar menu.

---

<div class="post-metadata">

### Author: ![Canapin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/canapin/32/119591_2.png) [@Canapin](https://meta.discourse.org/u/Canapin)
#### Post date: [April 17, 2023, 12:48pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/7 "2023-04-17T12:48:18Z")

</div>

It seems to be browser-related. It doesn’t happen on Firefox but it does on Chrome.

---

<div class="post-metadata">

### Author: ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)
#### Post date: [April 17, 2023, 12:49pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/8 "2023-04-17T12:49:03Z")

</div>

Ding ding ding. :slight_smile: I’ve just tried in Chrome and I can replicate :+1:

---

<div class="post-metadata">

### Author: ![Lilly](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/lilly/32/575047_2.png) [@Lilly](https://meta.discourse.org/u/Lilly)
#### Post date: [April 17, 2023, 12:50pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/9 "2023-04-17T12:50:28Z")

</div>

heh i was just going to try safari. yes the bug seems to be windows desktop chrome only. can’t replicate in safari or chrome on iOS desktop or mobile. seems to be a strictly windows desktop chrome thing.

---

<div class="post-metadata">

### Author: ![nizar9](https://avatars.discourse-cdn.com/v4/letter/n/9e8a1a/32.png) [@nizar9](https://meta.discourse.org/u/nizar9)
#### Post date: [April 19, 2023, 1:28am UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/10 "2023-04-19T01:28:55Z")

</div>

Hey,

It happens on Edge & Opera as well (I think that they’re both Chromium-based, so that explains the behavior).

**Priority/Severity** :  
Not urgent

**Platform** :  
Desktop Windows on Chromium-based browsers (Edge, Chrome and Opera so far).

**Description** :  
The drop down user menu doesn’t show up after using the search box and highlighting a suggestion.

**Reproducible steps** :

1. Type a keyword in the search box.
2. Hover one of the suggestions.
3. Click on the profile icon/image.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [April 21, 2023, 6:34pm 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>

Thanks, this should be fixed via:

> <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.

There’s a long-ish explanation in the PR description, the short version is that we were previously skipping the `clickOutside` event for the search menu when there was text selected. But we auto-select the search menu input text, so this switches to a different technique.

---

<div class="post-metadata">

### Author: ![pmusaraj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pmusaraj/32/119489_2.png) [@pmusaraj](https://meta.discourse.org/u/pmusaraj)
#### Post date: [April 24, 2023, 12:00pm UTC](https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/16 "2023-04-24T12:00:45Z")

</div>

This topic was automatically closed after 2 days. New replies are no longer allowed.
