From d9e2c23169a28be4c95b75a07145aaeece13cb41 Mon Sep 17 00:00:00 2001
From: pkupczyk <piotr.kupczyk@id.ethz.ch>
Date: Tue, 15 Feb 2022 15:23:57 +0100
Subject: [PATCH] Revert "SSDM-11169 : Properties overview in the new admin UI
 - improve performance of navigation browser by reducing the number of
 re-renders when a filter value is typed"

This reverts commit 1438b021b22746ec48f8b45a521449b4f55c4750.
---
 .../common/browser/BrowserController.js       | 67 +++++++++----------
 1 file changed, 31 insertions(+), 36 deletions(-)

diff --git a/openbis_ng_ui/src/js/components/common/browser/BrowserController.js b/openbis_ng_ui/src/js/components/common/browser/BrowserController.js
index 88547a584cb..cd761932f46 100644
--- a/openbis_ng_ui/src/js/components/common/browser/BrowserController.js
+++ b/openbis_ng_ui/src/js/components/common/browser/BrowserController.js
@@ -33,7 +33,6 @@ export default class BrowserController {
     context.initState({
       loaded: false,
       filter: '',
-      usedFilter: '',
       nodes: [],
       selectedId: null,
       selectedObject: null,
@@ -44,8 +43,12 @@ export default class BrowserController {
 
   load() {
     return this.doLoadNodes().then(loadedNodes => {
-      const { filter, nodes, selectedId, selectedObject } =
-        this.context.getState()
+      const {
+        filter,
+        nodes,
+        selectedId,
+        selectedObject
+      } = this.context.getState()
 
       let newNodes = this._createNodes(loadedNodes)
       newNodes = this._filterNodes(newNodes, filter)
@@ -61,7 +64,6 @@ export default class BrowserController {
 
       this.context.setState({
         loaded: true,
-        usedFilter: filter,
         nodes: newNodes
       })
     })
@@ -118,42 +120,35 @@ export default class BrowserController {
   }
 
   filterChange(newFilter) {
-    this.context.setState({
-      filter: newFilter
-    })
-
-    if (this.filterTimerId) {
-      clearTimeout(this.filterTimerId)
-      this.filterTimerId = null
-    }
-
-    this.filterTimerId = setTimeout(async () => {
-      const { filter, usedFilter, nodes, selectedId, selectedObject } =
-        this.context.getState()
+    const {
+      filter,
+      nodes,
+      selectedId,
+      selectedObject
+    } = this.context.getState()
 
-      let initialNodes = null
+    let initialNodes = null
 
-      if (filter.startsWith(usedFilter)) {
-        initialNodes = nodes
-      } else {
-        initialNodes = this.loadedNodes
-      }
+    if (newFilter.startsWith(filter)) {
+      initialNodes = nodes
+    } else {
+      initialNodes = this.loadedNodes
+    }
 
-      let newNodes = this._createNodes(initialNodes)
-      newNodes = this._filterNodes(newNodes, newFilter)
-      newNodes = this._setNodesExpanded(
-        newNodes,
-        this._getParentNodes(newNodes),
-        true
-      )
-      newNodes = this._setNodesSelected(newNodes, selectedId, selectedObject)
-      this._sortNodes(newNodes)
+    let newNodes = this._createNodes(initialNodes)
+    newNodes = this._filterNodes(newNodes, newFilter)
+    newNodes = this._setNodesExpanded(
+      newNodes,
+      this._getParentNodes(newNodes),
+      true
+    )
+    newNodes = this._setNodesSelected(newNodes, selectedId, selectedObject)
+    this._sortNodes(newNodes)
 
-      this.context.setState({
-        usedFilter: filter,
-        nodes: newNodes
-      })
-    }, 200)
+    this.context.setState({
+      filter: newFilter,
+      nodes: newNodes
+    })
   }
 
   nodeExpand(nodeId) {
-- 
GitLab