From a21ef85013f26fcc79d451c559ebd673841fd8a5 Mon Sep 17 00:00:00 2001 From: Rudy Fraser Date: Wed, 11 Nov 2026 09:35:06 -0500 Subject: [PATCH] feat(signup): open the browser's date picker from the date of birth row --- src/components/forms/DateField/index.web.tsx | 27 ++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/components/forms/DateField/index.web.tsx b/src/components/forms/DateField/index.web.tsx index 11a6b590f..1204045da 100644 --- a/src/components/forms/DateField/index.web.tsx +++ b/src/components/forms/DateField/index.web.tsx @@ -1,4 +1,4 @@ -import {forwardRef, useCallback} from 'react' +import {forwardRef, useCallback, useImperativeHandle, useRef} from 'react' import {StyleSheet, type TextInput, type TextInputProps} from 'react-native' // @ts-expect-error untyped import {unstable_createElement} from 'react-native-web' @@ -44,6 +44,27 @@ export function DateField({ maximumDate, minimumDate, }: DateFieldProps) { + const input = useRef(null) + + /* + * On native, focusing the field opens its picker. The browser only opens one + * from a user gesture and not on focus alone, so ask for it; where that is + * refused or unsupported the field is still focused and can be typed into. + */ + useImperativeHandle( + inputRef, + () => ({ + focus: () => { + input.current?.focus() + try { + input.current?.showPicker() + } catch {} + }, + blur: () => input.current?.blur(), + }), + [], + ) + const handleOnChange = useCallback( (e: any) => { const date = e.target.valueAsDate || e.target.value @@ -62,7 +83,9 @@ export function DateField({ >} + inputRef={ + input as unknown as React.Ref> + } label={label} onChange={handleOnChange} testID={testID} -- knotmirror 0.0.1