Add search bar component unmount handler, clean up search bar code
authorMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 11 Jun 2018 20:32:33 +0000 (22:32 +0200)
committerMichal Klobukowski <michal.klobukowski@contractors.roche.com>
Mon, 11 Jun 2018 20:32:33 +0000 (22:32 +0200)
Feature #13590

Arvados-DCO-1.1-Signed-off-by: Michal Klobukowski <michal.klobukowski@contractors.roche.com>

src/components/main-app-bar/search-bar/search-bar.tsx

index b2c95a9379a04f24454d315ecc37e12b58fa7c3e..d8c7edeeafa525c0edf0b4640945d1219a3fd314 100644 (file)
@@ -3,12 +3,8 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { AppBar, Toolbar, Typography, Grid, IconButton, Badge, Paper, Input, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
-import NotificationsIcon from '@material-ui/icons/Notifications';
-import PersonIcon from '@material-ui/icons/Person';
-import HelpIcon from '@material-ui/icons/Help';
+import { IconButton, Paper, StyleRulesCallback, withStyles, WithStyles } from '@material-ui/core';
 import SearchIcon from '@material-ui/icons/Search';
-import { AppBarProps } from '@material-ui/core/AppBar';
 
 interface SearchBarDataProps {
     value: string;
@@ -23,7 +19,6 @@ type SearchBarProps = SearchBarDataProps & SearchBarActionProps & WithStyles<Css
 
 interface SearchBarState {
     value: string;
-    prevValue: string;
 }
 
 const DEFAULT_SEARCH_DEBOUNCE = 1000;
@@ -31,8 +26,7 @@ const DEFAULT_SEARCH_DEBOUNCE = 1000;
 class SearchBar extends React.Component<SearchBarProps> {
 
     state: SearchBarState = {
-        value: "",
-        prevValue: ""
+        value: ""
     }
 
     timeout: NodeJS.Timer;
@@ -60,6 +54,10 @@ class SearchBar extends React.Component<SearchBarProps> {
         }
     }
 
+    componentWillUnmount() {
+        clearTimeout(this.timeout);
+    }
+
     handleSubmit = (event: React.FormEvent<HTMLFormElement>) => {
         event.preventDefault();
         clearTimeout(this.timeout);