From d9c1c6cb78923779a548ec0f4e739b1b0115e821 Mon Sep 17 00:00:00 2001 From: ivaosthu Date: Wed, 28 Dec 2016 23:36:01 +0100 Subject: [PATCH] Filter should be case insensitive. Closes #25 --- frontend/src/component/feature/list-component.jsx | 2 +- frontend/src/component/feature/list-container.jsx | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/component/feature/list-component.jsx b/frontend/src/component/feature/list-component.jsx index bed90978d2..87219dc1c0 100644 --- a/frontend/src/component/feature/list-component.jsx +++ b/frontend/src/component/feature/list-component.jsx @@ -39,7 +39,7 @@ export default class FeatureListComponent extends React.PureComponent { } setFilter (v) { - this.props.updateSetting('filter', typeof v === 'string' ? v.trim() : ''); + this.props.updateSetting('filter', typeof v === 'string' ? v : ''); } setSort (v) { diff --git a/frontend/src/component/feature/list-container.jsx b/frontend/src/component/feature/list-container.jsx index b064609d3f..d4e934f885 100644 --- a/frontend/src/component/feature/list-container.jsx +++ b/frontend/src/component/feature/list-container.jsx @@ -11,11 +11,12 @@ const mapStateToProps = (state) => { const settings = state.settings.toJS().feature || {}; let features = state.features.toJS(); if (settings.filter) { + const regex = new RegExp(settings.filter, 'i'); features = features.filter(feature => ( - feature.name.indexOf(settings.filter) > -1 || - feature.description.indexOf(settings.filter) > -1 || - feature.strategies.some(s => s && s.name && s.name.indexOf(settings.filter) > -1) + regex.test(feature.name) || + regex.test(feature.description) || + feature.strategies.some(s => s && s.name && regex.test(s.name)) ) ); }