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

Fix TextInput shadow props not update when setText on iOS #20634

Closed
wants to merge 1 commit into from

Conversation

zhongwuzw
Copy link
Contributor

@zhongwuzw zhongwuzw commented Aug 12, 2018

Fixes #20224

Test Plan:

The code as below, click TouchableOpacity, click textInput , edit text, then click TouchableOpacity again.

import React from "react";
import { View, Text, TextInput, TouchableOpacity } from "react-native";

export default class App extends React.Component {
  state = {
    isReactNative: true
  };

  insertText = () => {
    this.textInput.setNativeProps({ text: "ReactNative" });
  };

  render() {
    return (
      <View style={{ paddingTop: 128, alignItems: "center" }}>
        <TextInput
          style={{
            width: "100%",
            backgroundColor: "#ccc",
            fontSize: 48,
            textAlign: "center"
          }}
          ref={ref => {
            this.textInput = ref;
          }}
        />

        <TouchableOpacity style={{ padding: 16 }} onPress={this.insertText}>
          <Text style={{ fontSize: 24 }}>Insert ReactNative</Text>
        </TouchableOpacity>
      </View>
    );
  }
}

Release Notes:

[IOS] [BUGFIX] [TextInput] - Fix TextInput shadow props not update when update local data.

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Aug 12, 2018
@pull-bot
Copy link

Warnings
⚠️

📋 Release Notes - This PR appears to be missing Release Notes.

Generated by 🚫 dangerJS

Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

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

hramos has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Contributor

@hramos hramos left a comment

Choose a reason for hiding this comment

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

This does not appear to be the root cause of the bug. Can you explain the reasoning behind adding this line?

It seems like the actual bug would originate in RCTBaseTextInputView.m.

@zhongwuzw
Copy link
Contributor Author

@hramos Emm, I think it's not the cause from RCTBaseTextInputView.m. because we only call it when we compare it wether changed in shadow view. And because we don't update the text of RCTBaseTextInputShadowView, leads to wrong comparison.

@cpojer
Copy link
Contributor

cpojer commented Mar 5, 2019

What's the status of this PR?

Copy link
Contributor

@shergin shergin left a comment

Choose a reason for hiding this comment

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

_text represents the actual prop value, changing that not from JS does not seem right to me.

Why does this change fix the issue?

@zhongwuzw
Copy link
Contributor Author

I'll closing this because the issue already fixes.

@zhongwuzw zhongwuzw closed this Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Component: TextInput Related to the TextInput component. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants