From 3ea1294ad284cd99fdc2058bdeda346879e93f01 Mon Sep 17 00:00:00 2001 From: Yury Molodov Date: Sun, 21 Jan 2024 02:24:16 +0100 Subject: [PATCH] vmui: add autofocus to input for desktop version #5479 (#5592) --- .../src/components/Configurators/QueryEditor/QueryEditor.tsx | 4 +++- .../ExploreMetricsHeader/ExploreMetricsHeader.tsx | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/vmui/packages/vmui/src/components/Configurators/QueryEditor/QueryEditor.tsx b/app/vmui/packages/vmui/src/components/Configurators/QueryEditor/QueryEditor.tsx index 51b10a4fc..87fdd6234 100644 --- a/app/vmui/packages/vmui/src/components/Configurators/QueryEditor/QueryEditor.tsx +++ b/app/vmui/packages/vmui/src/components/Configurators/QueryEditor/QueryEditor.tsx @@ -8,6 +8,7 @@ import { QueryStats } from "../../../api/types"; import { partialWarning, seriesFetchedWarning } from "./warningText"; import { AutocompleteOptions } from "../../Main/Autocomplete/Autocomplete"; import { useQueryDispatch } from "../../../state/query/QueryStateContext"; +import useDeviceDetect from "../../../hooks/useDeviceDetect"; export interface QueryEditorProps { onChange: (query: string) => void; @@ -35,6 +36,7 @@ const QueryEditor: FC = ({ label, disabled = false }) => { + const { isMobile } = useDeviceDetect(); const [openAutocomplete, setOpenAutocomplete] = useState(false); const [caretPosition, setCaretPosition] = useState([0, 0]); @@ -115,7 +117,7 @@ const QueryEditor: FC = ({ value={value} label={label} type={"textarea"} - autofocus={!!value} + autofocus={!isMobile} error={error} warning={warning} onKeyDown={handleKeyDown} diff --git a/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx b/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx index 0d4151cb1..ae4d6818b 100644 --- a/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx +++ b/app/vmui/packages/vmui/src/components/ExploreMetrics/ExploreMetricsHeader/ExploreMetricsHeader.tsx @@ -71,7 +71,7 @@ const ExploreMetricsHeader: FC = ({ label="Job" placeholder="Please select job" onChange={onChangeJob} - autofocus={!job} + autofocus={!job && !!jobs.length && !isMobile} searchable />