diff --git a/app/vmui/packages/vmui/src/components/Main/Autocomplete/Autocomplete.tsx b/app/vmui/packages/vmui/src/components/Main/Autocomplete/Autocomplete.tsx index 021e05797c..3cb15557e8 100644 --- a/app/vmui/packages/vmui/src/components/Main/Autocomplete/Autocomplete.tsx +++ b/app/vmui/packages/vmui/src/components/Main/Autocomplete/Autocomplete.tsx @@ -56,13 +56,14 @@ const Autocomplete: FC = ({ const handleKeyDown = (e: KeyboardEvent) => { const { key, ctrlKey, metaKey, shiftKey } = e; const modifiers = ctrlKey || metaKey || shiftKey; + const hasOptions = foundOptions.length; - if (key === "ArrowUp" && !modifiers) { + if (key === "ArrowUp" && !modifiers && hasOptions) { e.preventDefault(); setFocusOption((prev) => prev <= 0 ? 0 : prev - 1); } - if (key === "ArrowDown" && !modifiers) { + if (key === "ArrowDown" && !modifiers && hasOptions) { e.preventDefault(); const lastIndex = foundOptions.length - 1; setFocusOption((prev) => prev >= lastIndex ? lastIndex : prev + 1); diff --git a/app/vmui/packages/vmui/src/utils/query-string.ts b/app/vmui/packages/vmui/src/utils/query-string.ts index 170a163795..333bd93550 100644 --- a/app/vmui/packages/vmui/src/utils/query-string.ts +++ b/app/vmui/packages/vmui/src/utils/query-string.ts @@ -5,7 +5,7 @@ import { MAX_QUERY_FIELDS } from "../constants/graph"; export const setQueryStringWithoutPageReload = (params: Record): void => { const w = window; if (w) { - const qsValue = Object.entries(params).map(([k, v]) => `${k}=${v}`).join("&"); + const qsValue = Object.entries(params).map(([k, v]) => `${k}=${encodeURIComponent(String(v))}`).join("&"); const qs = qsValue ? `?${qsValue}` : ""; const newurl = `${w.location.protocol}//${w.location.host}${w.location.pathname}${qs}${w.location.hash}`; w.history.pushState({ path: newurl }, "", newurl);