From c2c3ee875154d2b1615d8a95b8611db85f624484 Mon Sep 17 00:00:00 2001 From: Hardin Gray Date: Mon, 3 Feb 2025 15:46:23 -0500 Subject: [PATCH] chore: add support for `auto-capitalize` attribute. Force email to use lower-case. --- src/components/hv-text-field/index.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/components/hv-text-field/index.tsx b/src/components/hv-text-field/index.tsx index e68ac49cf..21655d931 100644 --- a/src/components/hv-text-field/index.tsx +++ b/src/components/hv-text-field/index.tsx @@ -41,6 +41,15 @@ const HvTextField = (props: HvComponentProps) => { const textContentType = (props.element.getAttribute('text-content-type') as TextContextType) || 'none'; + // Force email addresses to have no auto-capitalization, others use default + const defaultCapitalization = + keyboardType === 'email-address' ? 'none' : undefined; + const autoCapitalize = + (props.element.getAttribute('auto-capitalize') as + | 'none' + | 'sentences' + | 'words' + | 'characters') || defaultCapitalization; // Handlers const setFocus = (focused: boolean) => { @@ -104,6 +113,7 @@ const HvTextField = (props: HvComponentProps) => { props.options.registerInputHandler(ref); } }} + autoCapitalize={autoCapitalize} autoFocus={autoFocus} defaultValue={defaultValue} editable={editable}