@@ -80,7 +80,7 @@ const TextField = (props: InternalTextFieldProps) => {
80
80
enableErrors, // TODO: rename to enableValidation
81
81
validationMessageStyle,
82
82
validationMessagePosition = ValidationMessagePosition . BOTTOM ,
83
- retainValidationSpace = ! helperText ,
83
+ retainValidationSpace = ! helperText && ! bottomAccessory ,
84
84
// Char Counter
85
85
showCharCounter,
86
86
charCounterStyle,
@@ -123,11 +123,11 @@ const TextField = (props: InternalTextFieldProps) => {
123
123
const hidePlaceholder = shouldHidePlaceholder ( props , fieldState . isFocused ) ;
124
124
const retainTopMessageSpace = ! floatingPlaceholder && isEmpty ( trim ( label ) ) ;
125
125
const centeredContainerStyle = centered && styles . centeredContainer ;
126
- const centeredTextStyle = centered && styles . centeredText ;
126
+ const centeredTextStyle = centered && ! showCharCounter && styles . centeredText ;
127
127
const _labelStyle = useMemo ( ( ) => [ labelStyle , centeredTextStyle ] , [ labelStyle , centeredTextStyle ] ) ;
128
128
const _validationMessageStyle = useMemo ( ( ) => [ validationMessageStyle , centeredTextStyle ] ,
129
129
[ 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)
131
131
const inputStyle = useMemo ( ( ) => [ typographyStyle , colorStyle , others . style , hasValue && centeredTextStyle ] ,
132
132
[ typographyStyle , colorStyle , others . style , centeredTextStyle , hasValue ] ) ;
133
133
const dummyPlaceholderStyle = useMemo ( ( ) => [ inputStyle , styles . dummyPlaceholder ] , [ inputStyle ] ) ;
@@ -208,32 +208,36 @@ const TextField = (props: InternalTextFieldProps) => {
208
208
{ trailingAccessory }
209
209
{ /* </View> */ }
210
210
</ 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 >
231
240
</ View >
232
- { helperText && (
233
- < Text $textNeutralHeavy subtext marginT-s1 testID = { `${ props . testID } .helperText` } >
234
- { helperText }
235
- </ Text >
236
- ) }
237
241
</ View >
238
242
</ FieldContext . Provider >
239
243
) ;
0 commit comments