mirror of
https://github.com/thelounge/thelounge
synced 2025-02-16 21:28:23 +00:00
Merge pull request #1955 from thelounge/xpaw/fix-touch-select
Prevent user contextmenu from opening while selecting text
This commit is contained in:
commit
2640c2a15e
1 changed files with 7 additions and 7 deletions
|
@ -170,6 +170,12 @@ $(function() {
|
|||
});
|
||||
|
||||
viewport.on("click contextmenu", ".user", function(e) {
|
||||
// If user is selecting text, do not open context menu
|
||||
// This primarily only targets mobile devices where selection is performed with touch
|
||||
if (!window.getSelection().isCollapsed) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return showContextMenu(this, e);
|
||||
});
|
||||
|
||||
|
@ -218,13 +224,7 @@ $(function() {
|
|||
|
||||
chat.on("click", ".chat", function() {
|
||||
setTimeout(function() {
|
||||
var text = "";
|
||||
if (window.getSelection) {
|
||||
text = window.getSelection().toString();
|
||||
} else if (document.selection && document.selection.type !== "Control") {
|
||||
text = document.selection.createRange().text;
|
||||
}
|
||||
if (!text) {
|
||||
if (window.getSelection().isCollapsed) {
|
||||
focus();
|
||||
}
|
||||
}, 2);
|
||||
|
|
Loading…
Add table
Reference in a new issue