@@ -80,7 +80,7 @@ const TextField = (props: InternalTextFieldProps) => {
8080 enableErrors, // TODO: rename to enableValidation
8181 validationMessageStyle,
8282 validationMessagePosition = ValidationMessagePosition . BOTTOM ,
83- retainValidationSpace = ! helperText ,
83+ retainValidationSpace = ! helperText && ! bottomAccessory ,
8484 // Char Counter
8585 showCharCounter,
8686 charCounterStyle,
@@ -123,11 +123,11 @@ const TextField = (props: InternalTextFieldProps) => {
123123 const hidePlaceholder = shouldHidePlaceholder ( props , fieldState . isFocused ) ;
124124 const retainTopMessageSpace = ! floatingPlaceholder && isEmpty ( trim ( label ) ) ;
125125 const centeredContainerStyle = centered && styles . centeredContainer ;
126- const centeredTextStyle = centered && styles . centeredText ;
126+ const centeredTextStyle = centered && ! showCharCounter && styles . centeredText ;
127127 const _labelStyle = useMemo ( ( ) => [ labelStyle , centeredTextStyle ] , [ labelStyle , centeredTextStyle ] ) ;
128128 const _validationMessageStyle = useMemo ( ( ) => [ validationMessageStyle , centeredTextStyle ] ,
129129 [ validationMessageStyle , centeredTextStyle ] ) ;
130- const hasValue = fieldState . value !== undefined ;
130+ const hasValue = fieldState . value !== undefined ; // NOTE: not pressable if centered without a value (so can't center placeholder)
131131 const inputStyle = useMemo ( ( ) => [ typographyStyle , colorStyle , others . style , hasValue && centeredTextStyle ] ,
132132 [ typographyStyle , colorStyle , others . style , centeredTextStyle , hasValue ] ) ;
133133 const dummyPlaceholderStyle = useMemo ( ( ) => [ inputStyle , styles . dummyPlaceholder ] , [ inputStyle ] ) ;
@@ -208,32 +208,36 @@ const TextField = (props: InternalTextFieldProps) => {
208208 { trailingAccessory }
209209 { /* </View> */ }
210210 </ View >
211- < View row spread >
212- { validationMessagePosition === ValidationMessagePosition . BOTTOM && (
213- < ValidationMessage
214- enableErrors = { enableErrors }
215- validate = { others . validate }
216- validationMessage = { others . validationMessage }
217- validationIcon = { validationIcon }
218- validationMessageStyle = { _validationMessageStyle }
219- retainValidationSpace = { retainValidationSpace }
220- testID = { `${ props . testID } .validationMessage` }
221- />
222- ) }
223- { bottomAccessory }
224- { showCharCounter && (
225- < CharCounter
226- maxLength = { others . maxLength }
227- charCounterStyle = { charCounterStyle }
228- testID = { `${ props . testID } .charCounter` }
229- />
230- ) }
211+ < View row spread center = { centered } >
212+ < View flex = { ! centered } flexG = { centered } >
213+ { validationMessagePosition === ValidationMessagePosition . BOTTOM && (
214+ < ValidationMessage
215+ enableErrors = { enableErrors }
216+ validate = { others . validate }
217+ validationMessage = { others . validationMessage }
218+ validationIcon = { validationIcon }
219+ validationMessageStyle = { _validationMessageStyle }
220+ retainValidationSpace = { retainValidationSpace }
221+ testID = { `${ props . testID } .validationMessage` }
222+ />
223+ ) }
224+ { helperText && (
225+ < Text $textNeutralHeavy subtext marginT-s1 testID = { `${ props . testID } .helperText` } >
226+ { helperText }
227+ </ Text >
228+ ) }
229+ { bottomAccessory }
230+ </ View >
231+ < View >
232+ { showCharCounter && (
233+ < CharCounter
234+ maxLength = { others . maxLength }
235+ charCounterStyle = { charCounterStyle }
236+ testID = { `${ props . testID } .charCounter` }
237+ />
238+ ) }
239+ </ View >
231240 </ View >
232- { helperText && (
233- < Text $textNeutralHeavy subtext marginT-s1 testID = { `${ props . testID } .helperText` } >
234- { helperText }
235- </ Text >
236- ) }
237241 </ View >
238242 </ FieldContext . Provider >
239243 ) ;
0 commit comments