Nativebase: Input Floating Label not floating on production

Created on 21 Jul 2018  路  13Comments  路  Source: GeekyAnts/NativeBase

I am using floating labels on inputs to show what they must contain.

On development, it works perfectly, but when I create the app on production, the floating label is not floating.

Node: 8.10.0
npm: 6.1.0
react-native: 0.56
react: 16.4.1
native-base: 2.7.1

Expected behaviour:
floatinglabel issue2

Actual behaviour:
floatinglabel issue

onFirstNameChange(text) {
    this.props.firstNameChanged(text);
}
onLastNameChange(text) {
    this.props.lastNameChanged(text)
}
render() {
    return (
        <View style={{flex:1}}>
            <Form style={{flex:1}}>
                <Item floatingLabel style={{marginBottom: 10}}> 
                    <Label>{I18n.t('account first_name')}</Label>
                    <Input 
                        style={{color: "#000"}}
                        underlineColorAndroid='transparent'
                        placeholderTextColor="grey"
                        autoCapitalize='words'
                        value={this.props.firstName ? this.props.firstName : this.state.firstName}
                        onChangeText={this.onFirstNameChange.bind(this)}
                    />
                </Item>
                <Item floatingLabel style={{marginBottom: 10}}> 
                    <Label>{I18n.t('account last_name')}</Label>
                    <Input 
                        style={{color: "#000"}}
                        underlineColorAndroid='transparent'
                        placeholderTextColor="grey"
                        autoCapitalize='words'
                        value={this.props.lastName ? this.props.lastName : this.state.lastName}
                        onChangeText={this.onLastNameChange.bind(this)}
                    />
                </Item>
            </Form>
        </View>
    }
}

On componentDidMount I am loading the data to the state, the props are used when changing the values.

Happens on both iOS and Android.

awaiting response can't reproduce

Most helpful comment

@SupriyaKalghatgi I'm reproducing the issue above both on Android and iOS. It only happens in production.

All 13 comments

Same problem here, I tried to find a workaround but nothing :(

I ended up using the stackedlabel. Not the way I wanted, but at least I can proceed.

I did react-native init and tried the above code snippet
Tested in debug and release mode for Android, worked as expected in both these modes
I cannot reproduce this

Closing this today in case of no response

@SupriyaKalghatgi I'm reproducing the issue above both on Android and iOS. It only happens in production.

Something similar in 2.8.0 on release app version, but hiding

1ec797abf97fa57aaa68b02de1c9fbd12e036bcf526f43ce62 pimgpsh_fullsize_distr

+1 hiding and not updating state.

+1

this issue is still happening in release build. works fine in debug.
"react-native": "^0.57.4", "native-base": "^2.8.1",
screenshot_2019-01-21-14-36-06

+1

@SupriyaKalghatgi
I am able to solve the problem by doing a small change in the Item.js code. The fix is just change the code
https://github.com/GeekyAnts/NativeBase/blob/bc9e296be598979e374dccabd5fb26690f61a787/src/basic/Item.js#L101

to

if(this.inputProps.value){
    this.floatUp(-16);
}
else{
    this.floatBack();
}

And if the label gets trimmed if the value in the input field is present, to get rid of this, do a hack like, update the state of the fields with same values inside componentDidMount() after 250ms. Which shall change the label position and look shall be as expected.

@ClenetTech This was fixed and working fine

Was this page helpful?
0 / 5 - 0 ratings

Related issues

maphongba008 picture maphongba008  路  3Comments

Cotel picture Cotel  路  3Comments

Bundas picture Bundas  路  3Comments

bsiddiqui picture bsiddiqui  路  3Comments

natashache picture natashache  路  3Comments