about summary refs log tree commit diff
path: root/src/components/forms/DateField/index.tsx
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-02-21 11:25:42 -0800
committerGitHub <noreply@github.com>2025-02-21 11:25:42 -0800
commitca7116ec3b834644d89983b7f7f9ee63fe8f1aff (patch)
tree8158cbc4191d37c54835eaa4c579b527355988fd /src/components/forms/DateField/index.tsx
parent80e59d31d03afd62d41a301a85b66f6acb772c93 (diff)
downloadvoidsky-ca7116ec3b834644d89983b7f7f9ee63fe8f1aff.tar.zst
connect inputs together in signup (#7809)
Diffstat (limited to 'src/components/forms/DateField/index.tsx')
-rw-r--r--src/components/forms/DateField/index.tsx19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/components/forms/DateField/index.tsx b/src/components/forms/DateField/index.tsx
index eca4d5cbd..b8ecf2e6f 100644
--- a/src/components/forms/DateField/index.tsx
+++ b/src/components/forms/DateField/index.tsx
@@ -1,4 +1,4 @@
-import React from 'react'
+import {useCallback, useImperativeHandle} from 'react'
 import {Keyboard, View} from 'react-native'
 import DatePicker from 'react-native-date-picker'
 import {msg, Trans} from '@lingui/macro'
@@ -25,6 +25,7 @@ export const LabelText = TextField.LabelText
  */
 export function DateField({
   value,
+  inputRef,
   onChangeDate,
   testID,
   label,
@@ -36,7 +37,7 @@ export function DateField({
   const t = useTheme()
   const control = Dialog.useDialogControl()
 
-  const onChangeInternal = React.useCallback(
+  const onChangeInternal = useCallback(
     (date: Date | undefined) => {
       if (date) {
         const formatted = toSimpleDateString(date)
@@ -46,6 +47,20 @@ export function DateField({
     [onChangeDate],
   )
 
+  useImperativeHandle(
+    inputRef,
+    () => ({
+      focus: () => {
+        Keyboard.dismiss()
+        control.open()
+      },
+      blur: () => {
+        control.close()
+      },
+    }),
+    [control],
+  )
+
   return (
     <>
       <DateFieldButton