From 396d5a7421d21c69f81ccc042521b3ec8d8547f5 Mon Sep 17 00:00:00 2001
From: Eugen Ciur <eugen@papermerge.com>
Date: Sun, 27 Feb 2022 10:38:44 +0100
Subject: [PATCH] fix clicking bug

---
 app/modifiers/ui_select.js | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/app/modifiers/ui_select.js b/app/modifiers/ui_select.js
index 77fe62c..8bb30cf 100644
--- a/app/modifiers/ui_select.js
+++ b/app/modifiers/ui_select.js
@@ -9,6 +9,16 @@ class UISelect {
     Desktop like select
   **/
 
+  get DRAG_THRESHOLD() {
+    /*
+      Some mouse clicks are acompanied by slight mouse movements, which
+      makes 'clicks' look like mouse drag events. In order the avoid
+      this confusion, DRAG_THRESHOLD is introduced. Any rectangle with
+      height or width < DRAG_THRESHOLD will be discarded.
+    */
+    return 5;
+  }
+
   constructor(parent_selector) {
     /***
       x, y coordinates where selection started.
@@ -77,6 +87,11 @@ class UISelect {
         new Rectangle(left, top, width, height)
       );
 
+      if (width < this.DRAG_THRESHOLD && height < this.DRAG_THRESHOLD) {
+        console.log('Not passing DRAG_THRESHOLD. Ignored.');
+        return;
+      }
+
       this.select_nodes(selected_nodes);
       this.unselect_nodes(unselected_nodes);
     }
-- 
GitLab