Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed double sending of onTextChange events #365

Merged
merged 8 commits into from
Oct 25, 2018
Merged

Conversation

vkjr
Copy link
Contributor

@vkjr vkjr commented Oct 8, 2018

Two TextInput bugs fixed:

  1. now TextInput doesn't send "onChange" events when text was set from js side. That solves bug TextInput events repeats constantly #214
  2. I found a discrepancy between multiline and singleline TextInput in Qt. When new text assigned, singleline TextInput saves cursor position, whereas multiline one - doesn't. In second case that results in cursor jumping when we quickly type in text because typed text sent to js and then assigned again from js to Qt because defaultValue changed.

PR to check in status-react: status-im/status-mobile#6176
Here is a code that reveals second problem in js:

export default class ButtonReactNative extends Component {

  constructor(props) {
    super(props);
    this.state = { newtext: "" };
  }

  render() {
    return (
      <TextInput
        style={{ backgroundColor: "yellow", width: 300, height: 100 }}
        defaultValue={this.state.newtext}
        multiline={true}
        onChangeText={text => {
          this.setState({ newtext: text })
          console.log("new text: ", text)}
        }
      />
    );
  }
}

@vkjr vkjr changed the title [WIP]Fixed double sending of onTextChange events Fixed double sending of onTextChange events Oct 8, 2018
@vkjr vkjr requested review from rasom and maxhora October 8, 2018 09:44
@vkjr vkjr self-assigned this Oct 8, 2018
Copy link
Contributor

@maxhora maxhora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch!

@yenda
Copy link

yenda commented Oct 12, 2018

Awesome ! What's wrong with the circle ci ?

@vkjr
Copy link
Contributor Author

vkjr commented Oct 12, 2018

@yenda, we have one of standard react-native tests failing (because not implemented). Max recently temporary excluded it from test suite

@vkjr vkjr force-pushed the fix/textinput_events branch from c41cee5 to 1b56660 Compare October 19, 2018 10:51
@vkjr vkjr merged commit 8d26d71 into master Oct 25, 2018
@vkjr vkjr deleted the fix/textinput_events branch February 16, 2021 08:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants