NativeBase icon indicating copy to clipboard operation
NativeBase copied to clipboard

Floating Label does not reset position when input is cleared

Open brozef opened this issue 9 years ago • 11 comments

Floating label is not resetting to the blurred state when clearing input on both ios and android.

Versions

native-base: 2.1.5 react: 16.0.0-alpha.12 react-native: 0.45.0

Example

<Item floatingLabel light ref={item => { this.emailItem= item; }}>
  <Label>Email</Label>
  <Input
     getRef={input => { this.emailInput = input; }}
     returnKeyType='next'
     keyboardType='email-address'
     autoCapitalize='none'
     autoCorrect={false}
     onChangeText={email => this.setState({ email })}
     onSubmitEditing={() => this.submit()}
     value={this.state.email}
  />
</Item>
submit = () => {
  //these do not reset the floating label
  this.setState({email: ''});
  this.emailInput._root.clear();
  this.emailInput._root.blur();
  //this.emailItem._inputRef.clear();   //is undefined
  //this.emailItem._inputRef.blur();   //is undefined
}

Screenshots

Initial empty state:

Entering text:

After clear:

Expected clear() to reset floating label position (in the example, email label should look like password)

brozef avatar Jul 20 '17 04:07 brozef

Also running into this issue. Have tried .clear() as above, as well as

this._TextInput._root.setNativeProps({text: ""});

lukewlms avatar Jul 26 '17 19:07 lukewlms

@JoeNimble @lukecwilliams Did you check this with NativeBase 2.3.3?

SupriyaKalghatgi avatar Nov 08 '17 08:11 SupriyaKalghatgi

@SupriyaKalghatgi still an issue for me using 2.3.3

brozef avatar Nov 14 '17 01:11 brozef

@SupriyaKalghatgi still facing this issue using 2.3.3

harshada-bhanose avatar Dec 17 '17 11:12 harshada-bhanose

@SupriyaKalghatgi still facing this issue using 2.3.3

Nachox07 avatar Jan 12 '18 09:01 Nachox07

Hi guys, any update on this? Would you be happy to accept a PR to address it?

jribeiro avatar Jan 29 '18 19:01 jribeiro

@jribeiro Sure!

SupriyaKalghatgi avatar Jan 30 '18 04:01 SupriyaKalghatgi

PR #1606 Works for this.setState({email: ''}); but not for this.emailInput._root.clear(); because the clear function doesn't bubble up to the NB Input wrapper.

rizzomichaelg avatar Feb 19 '18 12:02 rizzomichaelg

Floating Label does not reset position when input is cleared, this is desired behavior

SupriyaKalghatgi avatar Mar 23 '18 12:03 SupriyaKalghatgi

Closing this issue

SupriyaKalghatgi avatar Mar 26 '18 15:03 SupriyaKalghatgi

Released with 2.5.0

SupriyaKalghatgi avatar Jun 08 '18 13:06 SupriyaKalghatgi