Skip to content

Commit c2c3ee8

Browse files
chore: add support for auto-capitalize attribute. Force email to use lower-case.
1 parent 093ffb2 commit c2c3ee8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Diff for: src/components/hv-text-field/index.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,15 @@ const HvTextField = (props: HvComponentProps) => {
4141
const textContentType =
4242
(props.element.getAttribute('text-content-type') as TextContextType) ||
4343
'none';
44+
// Force email addresses to have no auto-capitalization, others use default
45+
const defaultCapitalization =
46+
keyboardType === 'email-address' ? 'none' : undefined;
47+
const autoCapitalize =
48+
(props.element.getAttribute('auto-capitalize') as
49+
| 'none'
50+
| 'sentences'
51+
| 'words'
52+
| 'characters') || defaultCapitalization;
4453

4554
// Handlers
4655
const setFocus = (focused: boolean) => {
@@ -104,6 +113,7 @@ const HvTextField = (props: HvComponentProps) => {
104113
props.options.registerInputHandler(ref);
105114
}
106115
}}
116+
autoCapitalize={autoCapitalize}
107117
autoFocus={autoFocus}
108118
defaultValue={defaultValue}
109119
editable={editable}

0 commit comments

Comments
 (0)