mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
vmui: fix multi-line query (#3448)
* fix: remove prevent nav by up/down keys for multi-line query * fix: add query params encode in URL
This commit is contained in:
parent
ff1c654006
commit
8f501ca220
2 changed files with 4 additions and 3 deletions
|
@ -56,13 +56,14 @@ const Autocomplete: FC<AutocompleteProps> = ({
|
||||||
const handleKeyDown = (e: KeyboardEvent) => {
|
const handleKeyDown = (e: KeyboardEvent) => {
|
||||||
const { key, ctrlKey, metaKey, shiftKey } = e;
|
const { key, ctrlKey, metaKey, shiftKey } = e;
|
||||||
const modifiers = ctrlKey || metaKey || shiftKey;
|
const modifiers = ctrlKey || metaKey || shiftKey;
|
||||||
|
const hasOptions = foundOptions.length;
|
||||||
|
|
||||||
if (key === "ArrowUp" && !modifiers) {
|
if (key === "ArrowUp" && !modifiers && hasOptions) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setFocusOption((prev) => prev <= 0 ? 0 : prev - 1);
|
setFocusOption((prev) => prev <= 0 ? 0 : prev - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === "ArrowDown" && !modifiers) {
|
if (key === "ArrowDown" && !modifiers && hasOptions) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const lastIndex = foundOptions.length - 1;
|
const lastIndex = foundOptions.length - 1;
|
||||||
setFocusOption((prev) => prev >= lastIndex ? lastIndex : prev + 1);
|
setFocusOption((prev) => prev >= lastIndex ? lastIndex : prev + 1);
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { MAX_QUERY_FIELDS } from "../constants/graph";
|
||||||
export const setQueryStringWithoutPageReload = (params: Record<string, unknown>): void => {
|
export const setQueryStringWithoutPageReload = (params: Record<string, unknown>): void => {
|
||||||
const w = window;
|
const w = window;
|
||||||
if (w) {
|
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 qs = qsValue ? `?${qsValue}` : "";
|
||||||
const newurl = `${w.location.protocol}//${w.location.host}${w.location.pathname}${qs}${w.location.hash}`;
|
const newurl = `${w.location.protocol}//${w.location.host}${w.location.pathname}${qs}${w.location.hash}`;
|
||||||
w.history.pushState({ path: newurl }, "", newurl);
|
w.history.pushState({ path: newurl }, "", newurl);
|
||||||
|
|
Loading…
Reference in a new issue