fix: check if searchText is null (#1301)

This commit is contained in:
scil 2021-10-25 23:33:11 +08:00 committed by GitHub
parent a0165d1eee
commit 85a68d5fc3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -399,7 +399,7 @@
const children = get(item, childrenField) || [];
const title = get(item, titleField);
const searchIdx = title.indexOf(searchText);
const searchIdx = searchText ? title.indexOf(searchText) : -1;
const isHighlight =
searchState.startSearch && !isEmpty(searchText) && highlight && searchIdx !== -1;
const highlightStyle = `color: ${isBoolean(highlight) ? '#f50' : highlight}`;