File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -96,6 +96,9 @@ Animated:
9696 <Box >
9797 <PasswordField name = " password" />
9898 </Box >
99+ <Box >
100+ <TwoFactorTokenField name = " 2fa" />
101+ </Box >
99102 </Stack >
100103 </Form >
101104 )}
Original file line number Diff line number Diff line change @@ -6,14 +6,23 @@ import { ErrorText } from './ErrorText'
66
77export interface TwoFactorTokenFieldProps extends InputProps {
88 name : string
9+ autoFocus ?: boolean
910}
1011
1112export const TwoFactorTokenField : React . FC < TwoFactorTokenFieldProps > = ( {
1213 name,
14+ autoFocus = false ,
1315 ...props
1416} ) => {
1517 const theme = useTheme ( )
16- const [ field ] = useField ( name )
18+ const [ { onBlur, ...field } ] = useField ( name )
19+ const ref = React . useRef < HTMLInputElement > ( )
20+
21+ React . useEffect ( ( ) => {
22+ if ( autoFocus && ref . current ) {
23+ ref . current . focus ( )
24+ }
25+ } , [ ] )
1726 return (
1827 < >
1928 < Input
@@ -23,12 +32,14 @@ export const TwoFactorTokenField: React.FC<TwoFactorTokenFieldProps> = ({
2332 placeholder = "123456"
2433 mb = { 1 }
2534 size = "lg"
35+ maxW = "9rem"
2636 inputMode = "numeric" // Show numeric keyboard on mobile
2737 autoComplete = "one-time-code"
2838 pattern = "[0-9]{6}"
2939 textAlign = "center"
30- fontSize = "1.8rem "
40+ fontSize = "1.6rem "
3141 fontFamily = { theme . fonts . mono }
42+ ref = { ref as any }
3243 { ...field }
3344 { ...props }
3445 />
You can’t perform that action at this time.
0 commit comments