@@ -340,6 +340,10 @@ export default class TextField extends BaseInput {
340
340
return this . shouldFakePlaceholder ( ) ? ( this . shouldShowTopError ( ) ? undefined : 25 ) : undefined ;
341
341
}
342
342
343
+ getTopErrorsPosition ( ) {
344
+ return ! this . props . title && this . shouldShowTopError ( ) ? { top : Constants . isIOS ? - 25 : - 27 } : undefined ;
345
+ }
346
+
343
347
isDisabled ( ) {
344
348
return this . props . editable === false ;
345
349
}
@@ -397,6 +401,11 @@ export default class TextField extends BaseInput {
397
401
return ! expandable && rightButtonProps && rightButtonProps . iconSource ;
398
402
}
399
403
404
+ shouldRenderTitle ( ) {
405
+ const { floatingPlaceholder, title} = this . getThemeProps ( ) ;
406
+ return ! floatingPlaceholder && title ;
407
+ }
408
+
400
409
onPressRightButton = ( ) => {
401
410
_ . invoke ( this . props , 'rightButtonProps.onPress' ) ;
402
411
} ;
@@ -419,6 +428,7 @@ export default class TextField extends BaseInput {
419
428
onLayout = { this . onPlaceholderLayout }
420
429
style = { [
421
430
this . styles . placeholder ,
431
+ this . getTopErrorsPosition ( ) ,
422
432
typography ,
423
433
// TODO: we need to exclude completely any dependency on line height
424
434
// in this component since it always breaks alignments
@@ -467,10 +477,10 @@ export default class TextField extends BaseInput {
467
477
}
468
478
469
479
renderTitle ( ) {
470
- const { floatingPlaceholder , title, titleColor, titleStyle} = this . getThemeProps ( ) ;
480
+ const { title, titleColor, titleStyle} = this . getThemeProps ( ) ;
471
481
const color = this . getStateColor ( titleColor || PLACEHOLDER_COLOR_BY_STATE ) ;
472
482
473
- if ( ! floatingPlaceholder && title ) {
483
+ if ( this . shouldRenderTitle ( ) ) {
474
484
return < Text style = { [ { color} , this . styles . topLabel , this . styles . label , titleStyle ] } > { title } </ Text > ;
475
485
}
476
486
}
@@ -636,7 +646,7 @@ export default class TextField extends BaseInput {
636
646
return (
637
647
< TouchableOpacity
638
648
{ ...others } accessibilityLabel = { accessibilityLabel }
639
- style = { [ this . styles . rightButton , style ] } onPress = { this . onPressRightButton }
649
+ style = { [ this . styles . rightButton , this . getTopErrorsPosition ( ) , style ] } onPress = { this . onPressRightButton }
640
650
>
641
651
< Image
642
652
pointerEvents = "none"
@@ -654,7 +664,7 @@ export default class TextField extends BaseInput {
654
664
655
665
if ( rightIconSource ) {
656
666
return (
657
- < View style = { this . styles . rightIcon } pointerEvents = "none" >
667
+ < View style = { [ this . styles . rightButton , this . getTopErrorsPosition ( ) ] } pointerEvents = "none" >
658
668
< Image source = { rightIconSource } resizeMode = { 'center' } style = { [ this . styles . rightButtonImage , rightIconStyle ] } />
659
669
</ View >
660
670
) ;
@@ -739,7 +749,7 @@ export default class TextField extends BaseInput {
739
749
} ;
740
750
}
741
751
742
- function createStyles ( { centered, multiline, hideUnderline } , rightItemTopPadding = 0 ) {
752
+ function createStyles ( { centered, multiline, title , floatingPlaceholder } , rightItemTopPadding = 0 ) {
743
753
const itemTopPadding = Constants . isIOS ? ( rightItemTopPadding - 3 ) : ( rightItemTopPadding - 1 ) ;
744
754
745
755
return StyleSheet . create ( {
@@ -805,12 +815,6 @@ function createStyles({centered, multiline, hideUnderline}, rightItemTopPadding
805
815
rightElement : {
806
816
paddingRight : ICON_SIZE + ICON_LEFT_PADDING
807
817
} ,
808
- rightIcon : {
809
- position : 'absolute' ,
810
- right : 0 ,
811
- alignSelf : 'flex-start' ,
812
- paddingTop : itemTopPadding
813
- } ,
814
818
rightButton : {
815
819
position : 'absolute' ,
816
820
right : 0 ,
0 commit comments