diff options
author | Samuel Newman <mozzius@protonmail.com> | 2024-03-13 23:34:01 +0000 |
---|---|---|
committer | Samuel Newman <mozzius@protonmail.com> | 2024-03-13 23:34:01 +0000 |
commit | 9f5289a1017856c303d7fefe28327b30eac3a909 (patch) | |
tree | 85ac5c71acc5410b77e9870618a17ed24d29be67 /src/components/forms/TextField.tsx | |
parent | f5b39f2755bdf62b79a7310e58e70fbcc79ac854 (diff) | |
download | voidsky-9f5289a1017856c303d7fefe28327b30eac3a909.tar.zst |
alf the login form
Diffstat (limited to 'src/components/forms/TextField.tsx')
-rw-r--r-- | src/components/forms/TextField.tsx | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/components/forms/TextField.tsx b/src/components/forms/TextField.tsx index b37f4bfae..3cffe5b2b 100644 --- a/src/components/forms/TextField.tsx +++ b/src/components/forms/TextField.tsx @@ -14,6 +14,7 @@ import {useTheme, atoms as a, web, android} from '#/alf' import {Text} from '#/components/Typography' import {useInteractionState} from '#/components/hooks/useInteractionState' import {Props as SVGIconProps} from '#/components/icons/common' +import {mergeRefs} from '#/lib/merge-refs' const Context = React.createContext<{ inputRef: React.RefObject<TextInput> | null @@ -128,6 +129,7 @@ export type InputProps = Omit<TextInputProps, 'value' | 'onChangeText'> & { value: string onChangeText: (value: string) => void isInvalid?: boolean + inputRef?: React.RefObject<TextInput> } export function createInput(Component: typeof TextInput) { @@ -137,6 +139,7 @@ export function createInput(Component: typeof TextInput) { value, onChangeText, isInvalid, + inputRef, ...rest }: InputProps) { const t = useTheme() @@ -161,19 +164,22 @@ export function createInput(Component: typeof TextInput) { ) } + const refs = mergeRefs([ctx.inputRef, inputRef!].filter(Boolean)) + return ( <> <Component accessibilityHint={undefined} {...rest} accessibilityLabel={label} - ref={ctx.inputRef} + ref={refs} value={value} onChangeText={onChangeText} onFocus={ctx.onFocus} onBlur={ctx.onBlur} placeholder={placeholder || label} placeholderTextColor={t.palette.contrast_500} + keyboardAppearance={t.name === 'light' ? 'light' : 'dark'} hitSlop={HITSLOP_20} style={[ a.relative, |