ui: Add an additional 'more than 1 char' check for selection (#6022)

We'd rather 'play it safe' for our selection detection (which avoids
following links if you have some text selected). This commit adds an
additional check of 'more than 1 character' to the 'isSelected' check.
This is based on the fact that it's far quicker to type the character so
why would a user select on character? This therefore caters for any
fairly large (in the scheme of things) incidential mouse moves whilst
clicking a link.

Overall this is probably overkill
This commit is contained in:
John Cowen 2019-07-16 17:05:09 +01:00 committed by John Cowen
parent cf83e9e8ad
commit 39860ae995
1 changed files with 2 additions and 1 deletions

View File

@ -5,7 +5,8 @@ const isSelecting = function(win = window) {
const selection = win.getSelection();
let selecting = false;
try {
selecting = 'isCollapsed' in selection && !selection.isCollapsed;
selecting =
'isCollapsed' in selection && !selection.isCollapsed && selection.toString().length > 1;
} catch (e) {
// passthrough
}