hotfix: Add check to confirm variable are string (#8358)

This commit is contained in:
Rishabh Rathod 2021-10-18 23:08:34 +05:30 committed by GitHub
parent 31476092cc
commit 6693c62396
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -116,8 +116,12 @@ const isModalOpenSelector = (state: AppState) =>
const searchQuerySelector = (state: AppState) => state.ui.globalSearch.query;
const isMatching = (text = "", query = "") =>
text?.toLowerCase().indexOf(query?.toLowerCase()) > -1;
const isMatching = (text = "", query = "") => {
if (typeof text === "string" && typeof query === "string") {
return text.toLowerCase().indexOf(query.toLowerCase()) > -1;
}
return false;
};
const getQueryIndexForSorting = (item: SearchItem, query: string) => {
if (item.kind === SEARCH_ITEM_TYPES.document) {
@ -169,6 +173,13 @@ function GlobalSearch() {
const modalOpen = useSelector(isModalOpenSelector);
const dispatch = useDispatch();
const [snippets, setSnippetsState] = useState([]);
const [query, setQueryInState] = useState("");
const setQuery = useCallback(
(value: string) => {
setQueryInState(value);
},
[setQueryInState],
);
const optionalFilterMeta = useSelector(
(state: AppState) => state.ui.globalSearch.filterContext.fieldMeta,
);
@ -202,10 +213,7 @@ function GlobalSearch() {
dispatch(toggleShowGlobalSearchModal());
dispatch(cancelSnippet());
};
const [query, setQueryInState] = useState("");
const setQuery = useCallback((query: string) => {
setQueryInState(query);
}, []);
const scrollPositionRef = useRef(0);
const [