Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Better detect text selection in search input #21202

Merged
merged 1 commit into from Apr 21, 2023

Conversation

pmusaraj
Copy link
Contributor

@pmusaraj pmusaraj commented Apr 21, 2023

Followup to 17ba00c. Fix for https://meta.discourse.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.

Followup to 17ba00c.
Fix for https://meta.discourse.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 some text and clicking. This means that when selecting text in
the search input, at the end of the selection event, a click event was
triggered. And if that click event happened to be outside of the search
menu, then the menu would be dismissed.

Previously, we fixed this by checked if a current text selection was
present. But that results in a small side-effect of not switching to
other menus. This PR switches to setting a flag during `mouseDown` and
then using that flag when evaluating whether to trigger clickOutside or
not.
@pmusaraj pmusaraj merged commit 34ffc00 into main Apr 21, 2023
13 checks passed
@pmusaraj pmusaraj deleted the search-selection-tweak branch April 21, 2023 18:30
@discoursebot
Copy link

This pull request has been mentioned on Discourse Meta. There might be relevant details there:

https://meta.discourse.org/t/cant-switch-from-search-drop-down-to-user-menu-when-text-selected-on-chrome/261917/15

ChadBoschert pushed a commit to apt-crowd/discourse that referenced this pull request Apr 26, 2023
Followup to 17ba00c.
Fix for https://meta.discourse.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 some text and clicking. This means that when selecting text in
the search input, at the end of the selection event, a click event was
triggered. And if that click event happened to be outside of the search
menu, then the menu would be dismissed.

Previously, we fixed this by checked if a current text selection was
present. But that results in a small side-effect of not switching to
other menus. This PR switches to setting a flag during `mouseDown` and
then using that flag when evaluating whether to trigger clickOutside or
not.
enduvar pushed a commit to ForgottenWorld/discourse that referenced this pull request Sep 8, 2023
Followup to 17ba00c.
Fix for https://meta.discourse.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 some text and clicking. This means that when selecting text in
the search input, at the end of the selection event, a click event was
triggered. And if that click event happened to be outside of the search
menu, then the menu would be dismissed.

Previously, we fixed this by checked if a current text selection was
present. But that results in a small side-effect of not switching to
other menus. This PR switches to setting a flag during `mouseDown` and
then using that flag when evaluating whether to trigger clickOutside or
not.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants