hotfix: Add check to confirm variable are string (#8358)
This commit is contained in:
parent
31476092cc
commit
6693c62396
|
|
@ -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 [
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user