diff --git a/src/app/components/BtnInput.tsx b/src/app/components/BtnInput.tsx index 26a1154e..468dacfd 100644 --- a/src/app/components/BtnInput.tsx +++ b/src/app/components/BtnInput.tsx @@ -1,3 +1,4 @@ +import { useEffect, useRef } from 'preact/hooks' import { Octicon } from '.' type BtnInputProps = { @@ -5,19 +6,28 @@ type BtnInputProps = { label?: string, large?: boolean, type?: 'number' | 'text', + doSelect?: number, value?: string, onChange?: (value: string) => unknown, } -export function BtnInput({ icon, label, large, type, value, onChange }: BtnInputProps) { +export function BtnInput({ icon, label, large, type, doSelect, value, onChange }: BtnInputProps) { const onKeyUp = onChange === undefined ? () => {} : (e: any) => { const value = (e.target as HTMLInputElement).value if (type !== 'number' || (!value.endsWith('.') && !isNaN(Number(value)))) { onChange?.(value) } } + + const ref = useRef(null) + useEffect(() => { + if (doSelect && ref.current) { + ref.current.select() + } + }, [doSelect]) + return
e.stopPropagation()}> {icon && Octicon[icon]} {label && {label}} - +
} diff --git a/src/app/pages/Generator.tsx b/src/app/pages/Generator.tsx index e09229e9..b667dc98 100644 --- a/src/app/pages/Generator.tsx +++ b/src/app/pages/Generator.tsx @@ -147,7 +147,7 @@ export function Generator({ lang, changeTitle, version, onChangeVersion, categor
{modelConfig.path && - +
{presetResults.map(preset => loadPreset(preset)} />)}