vmui: add autofocus to input for desktop version #5479 (#5592)

This commit is contained in:
Yury Molodov 2024-01-21 02:24:16 +01:00 committed by GitHub
parent 7fba73ce11
commit 3ea1294ad2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 2 deletions

View File

@ -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<QueryEditorProps> = ({
label,
disabled = false
}) => {
const { isMobile } = useDeviceDetect();
const [openAutocomplete, setOpenAutocomplete] = useState(false);
const [caretPosition, setCaretPosition] = useState([0, 0]);
@ -115,7 +117,7 @@ const QueryEditor: FC<QueryEditorProps> = ({
value={value}
label={label}
type={"textarea"}
autofocus={!!value}
autofocus={!isMobile}
error={error}
warning={warning}
onKeyDown={handleKeyDown}

View File

@ -71,7 +71,7 @@ const ExploreMetricsHeader: FC<ExploreMetricsHeaderProps> = ({
label="Job"
placeholder="Please select job"
onChange={onChangeJob}
autofocus={!job}
autofocus={!job && !!jobs.length && !isMobile}
searchable
/>
</div>