diff --git a/frontend/package.json b/frontend/package.json index 5e56d633c2..86e0ab7661 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -53,6 +53,7 @@ "babel-loader": "^8.0.6", "clean-webpack-plugin": "^3.0.0", "css-loader": "^2.1.1", + "debounce": "^1.2.0", "debug": "^4.1.1", "enzyme": "^3.9.0", "enzyme-adapter-react-16": "^1.11.0", diff --git a/frontend/src/component/feature/list-component.jsx b/frontend/src/component/feature/list-component.jsx index fbdc926e1a..1352e9de0b 100644 --- a/frontend/src/component/feature/list-component.jsx +++ b/frontend/src/component/feature/list-component.jsx @@ -1,8 +1,9 @@ import React from 'react'; import PropTypes from 'prop-types'; -import Feature from './feature-list-item-component'; +import { debounce } from "debounce"; import { Link } from 'react-router-dom'; import { Icon, FABButton, Textfield, Menu, MenuItem, Card, CardActions, List } from 'react-mdl'; +import Feature from './feature-list-item-component'; import { MenuItemWithIcon, DropdownButton, styles as commonStyles } from '../common'; import styles from './feature.scss'; import { CREATE_FEATURE } from '../../permissions'; @@ -21,6 +22,14 @@ export default class FeatureListComponent extends React.Component { hasPermission: PropTypes.func.isRequired, }; + constructor(props) { + super(); + this.state = { + filter: props.settings.filter, + updateFilter: debounce(props.updateSetting.bind(this, 'filter'), 200) + } + } + componentDidMount() { if (this.props.fetchFeatureToggles) { this.props.fetchFeatureToggles(); @@ -34,7 +43,9 @@ export default class FeatureListComponent extends React.Component { } setFilter(v) { - this.props.updateSetting('filter', typeof v === 'string' ? v : ''); + const value = typeof v === 'string' ? v : ''; + this.setState({filter: value}); + this.state.updateFilter(value) } setSort(v) { @@ -51,7 +62,7 @@ export default class FeatureListComponent extends React.Component {