From 46148e0a7f8347b0635b71b41279601c4a779864 Mon Sep 17 00:00:00 2001
From: Hermann <blumh@student.ethz.ch>
Date: Fri, 25 May 2018 18:34:00 +0200
Subject: [PATCH] fix: too many updates of list search

---
 src/views/tableView.js | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/views/tableView.js b/src/views/tableView.js
index 5536126..f352aac 100644
--- a/src/views/tableView.js
+++ b/src/views/tableView.js
@@ -46,6 +46,7 @@ export default class TableView {
     this.tableKeys = keys;
     this.tileContent = tileContent;
     this.clickOnRows = clickOnRows;
+    this.searchValue = '';
   }
 
   getItemData(data) {
@@ -94,7 +95,13 @@ export default class TableView {
           m(Search, {
             textfield: {
               label: 'Search',
-              onChange: ({ value }) => { controller.debouncedSearch(value); },
+              onChange: ({ value }) => {
+                // this is called not only if the value changes, but also the focus.
+                // we only want to change the search of the value is changed, therefore we
+                // have to track changes in the search value
+                if (value !== this.searchValue) controller.debouncedSearch(value);
+                this.searchValue = value;
+              },
             },
             fullWidth: false,
           }),
-- 
GitLab