From 6935de3c258d07d9497b50a4e68f9785fccd5b96 Mon Sep 17 00:00:00 2001 From: DD Liu <liudi@media.mit.edu> Date: Thu, 25 May 2017 14:31:36 -0400 Subject: [PATCH] filter items! Ignore case except turkish --- src/components/library/library.jsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/components/library/library.jsx b/src/components/library/library.jsx index 331d94f2c..4d737d390 100644 --- a/src/components/library/library.jsx +++ b/src/components/library/library.jsx @@ -47,7 +47,9 @@ class LibraryComponent extends React.Component { onRequestClose={this.props.onRequestClose} > <div className={styles.libraryScrollGrid}> - {this.props.data.map((dataItem, itemId) => { + {this.props.data.filter(dataItem => + dataItem.name.toLowerCase().indexOf(this.state.filterQuery.toLowerCase()) !== -1 + ).map((dataItem, itemId) => { const scratchURL = dataItem.md5 ? `https://cdn.assets.scratch.mit.edu/internalapi/asset/${dataItem.md5}/get/` : dataItem.rawURL; @@ -71,6 +73,7 @@ class LibraryComponent extends React.Component { LibraryComponent.propTypes = { data: PropTypes.arrayOf( /* eslint-disable react/no-unused-prop-types, lines-around-comment */ + // An item in the library PropTypes.shape({ // @todo remove md5/rawURL prop from library, refactor to use storage md5: PropTypes.string, -- GitLab