mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-11 20:00:29 +01:00
Fix autoSelect for PlainInput.tsx
This commit is contained in:
@@ -32,6 +32,7 @@ export const PlainInput = forwardRef<HTMLInputElement, PlainInputProps>(function
|
||||
size = 'md',
|
||||
type = 'text',
|
||||
validate,
|
||||
autoSelect,
|
||||
...props
|
||||
}: PlainInputProps,
|
||||
ref,
|
||||
@@ -39,11 +40,15 @@ export const PlainInput = forwardRef<HTMLInputElement, PlainInputProps>(function
|
||||
const [obscured, setObscured] = useStateWithDeps(type === 'password', [type]);
|
||||
const [currentValue, setCurrentValue] = useState(defaultValue ?? '');
|
||||
const [focused, setFocused] = useState(false);
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const handleFocus = useCallback(() => {
|
||||
setFocused(true);
|
||||
if (autoSelect) {
|
||||
inputRef.current?.select();
|
||||
}
|
||||
onFocus?.();
|
||||
}, [onFocus]);
|
||||
}, [autoSelect, onFocus]);
|
||||
|
||||
const handleBlur = useCallback(() => {
|
||||
setFocused(false);
|
||||
|
||||
Reference in New Issue
Block a user