@@ -125,7 +125,7 @@ export default class TextField extends BaseInput {
125125 */
126126 transformer : PropTypes . func ,
127127 /**
128- * Pass to render a prefix text as part of the input
128+ * Pass to render a prefix text as part of the input (doesn't work with floatingPlaceholder)
129129 */
130130 prefix : PropTypes . string ,
131131 /**
@@ -172,7 +172,11 @@ export default class TextField extends BaseInput {
172172 iconColor : PropTypes . string ,
173173 onPress : PropTypes . func ,
174174 style : PropTypes . oneOfType ( [ PropTypes . object , PropTypes . number ] )
175- } )
175+ } ) ,
176+ /**
177+ * Pass to render a leading icon to the TextInput value. Accepts Image props (doesn't work with floatingPlaceholder)
178+ */
179+ leadingIcon : PropTypes . shape ( Image . propTypes )
176180 } ;
177181
178182 static defaultProps = {
@@ -310,8 +314,7 @@ export default class TextField extends BaseInput {
310314 }
311315
312316 getTopPaddings ( ) {
313- const { floatingPlaceholder} = this . getThemeProps ( ) ;
314- return floatingPlaceholder ? ( this . shouldShowTopError ( ) ? undefined : 25 ) : undefined ;
317+ return this . shouldFakePlaceholder ( ) ? ( this . shouldShowTopError ( ) ? undefined : 25 ) : undefined ;
315318 }
316319
317320 isDisabled ( ) {
@@ -345,8 +348,9 @@ export default class TextField extends BaseInput {
345348 }
346349
347350 shouldFakePlaceholder ( ) {
348- const { floatingPlaceholder, centered} = this . getThemeProps ( ) ;
349- return Boolean ( floatingPlaceholder && ! centered && ! this . shouldShowTopError ( ) ) ;
351+ const { floatingPlaceholder, centered, leadingIcon, prefix} = this . getThemeProps ( ) ;
352+
353+ return ! leadingIcon && ! prefix && Boolean ( floatingPlaceholder && ! centered && ! this . shouldShowTopError ( ) ) ;
350354 }
351355
352356 shouldShowError ( ) {
@@ -389,6 +393,9 @@ export default class TextField extends BaseInput {
389393 style = { [
390394 this . styles . placeholder ,
391395 typography ,
396+ // TODO: we need to exclude completely any dependency on line height
397+ // in this component since it always breaks alignments
398+ { lineHeight : undefined } ,
392399 {
393400 transform : [
394401 {
@@ -627,7 +634,7 @@ export default class TextField extends BaseInput {
627634 }
628635
629636 render ( ) {
630- const { expandable, containerStyle, underlineColor, useTopErrors, hideUnderline} = this . getThemeProps ( ) ;
637+ const { expandable, containerStyle, underlineColor, useTopErrors, hideUnderline, leadingIcon } = this . getThemeProps ( ) ;
631638 const underlineStateColor = this . getStateColor ( underlineColor || UNDERLINE_COLOR_BY_STATE ) ;
632639
633640 return (
@@ -642,6 +649,7 @@ export default class TextField extends BaseInput {
642649 { paddingTop : this . getTopPaddings ( ) }
643650 ] }
644651 >
652+ { leadingIcon && < Image { ...leadingIcon } /> }
645653 { this . renderPrefix ( ) }
646654 { this . renderPlaceholder ( ) }
647655 { expandable ? this . renderExpandableInput ( ) : this . renderTextInput ( ) }
0 commit comments