Skip to content

TagSpaces is an offline, open source, document manager with tagging support

fix: issue with empty search query

Ilian Sapundshiev14b8996899c9
diff --git a/app/components/Search.tsx b/app/components/Search.tsx
index 2ad1d483c..5d29cc266 100644
--- a/app/components/Search.tsx
+++ b/app/components/Search.tsx
@@ -434,10 +434,16 @@ const Search = (props: Props) => {
const parseTextQuery = (identifier: string) => {
const extractedTags = [];
- const txt = textQuery.current
- .trim()
- .replace(new RegExp(escapeRegExp(identifier) + '\\s+', 'g'), identifier);
- const textQueryParts = txt.split(' ');
+ let query = textQuery.current;
+ if (query && query.length > 0) {
+ query = query
+ .trim()
+ .replace(
+ new RegExp(escapeRegExp(identifier) + '\\s+', 'g'),
+ identifier
+ );
+ }
+ const textQueryParts = query.split(' ');
let newTextQuery = '';
if (textQueryParts) {
// && textQueryParts.length > 1) {