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

[TextInput][iOS 11] - Does not change the text color without focus. #16200

Closed
douglasjunior opened this issue Oct 4, 2017 · 8 comments
Closed
Labels
Component: TextInput Related to the TextInput component. Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon.

Comments

@douglasjunior
Copy link

Is this a bug report?

Yes, it seems like a Bug to me. Similar to #15650 and #14645

Changing the style has no effect. Only after the user focuses on the field does the color change.

iOS 9 works.
iOS 10 not tested yet.
iOS 11 not works.

Environment

Environment:
OS: macOS Sierra 10.12.6
Node: 6.11.3
Yarn: 1.0.2
npm: 5.4.2
Watchman: 4.9.0
Xcode: Xcode 9.0 Build version 9A235
Android Studio: EAP AI-171.4333198 AI-171.4333198

Packages: (wanted => installed)
react: 16.0.0-alpha.12 => 16.0.0-alpha.12
react-native: 0.48.4 => 0.48.4

The problem also exists in RN 0.46.4.

Steps to Reproduce

Create a component that contains a TextInpt and two Buttons that change the color.

class Example extends Component {
    state = {
        color: '#ff0000'
    }
    render() {
        const style = { color: this.state.color };
        return (
            <View style={{ marginTop: 20 }}>
                <TextInput style={style} value='Some Text Here' />
                <Button onPress={() => this.setState({ color: '#0000ff' })} title="Blue" />
                <Button onPress={() => this.setState({ color: '#ff0000' })} title="Red" />
            </View>
        )
    }
}

Expected vs Actual Behavior

textinput-color

@shergin
Copy link
Contributor

shergin commented Oct 5, 2017

Not sure that we can fix this. I hope it will be fixed by Apple soon.

http://www.openradar.me/33104437
https://stackoverflow.com/questions/46178078/ios-11-public-beta-9-uitextfield-textcolor-cant-be-changed-when-no-keyboard

@ghost
Copy link

ghost commented Oct 13, 2017

Not a solution, but adding multiline={true} seems to work. Any better workaround for this issue?

@shergin
Copy link
Contributor

shergin commented Oct 13, 2017

@joelandplus This is probably because multiline TextInput uses UITextView under the hood, whereas single line one uses UITextField.

@RomualdPercereau
Copy link

For now you can setState a new placeholder color to "force" the reload of the color.

@douglasjunior
Copy link
Author

Changing the font size also "force" the color update.

class Example extends Component {
    state = {
        color: '#ff0000',
        fontSize: 28
    }
    componentDidMount() {
        Splash.hide();
    }
    render() {
        return (
            <View style={{ marginTop: 20 }}>
                <TextInput style={{ color: this.state.color, fontSize: this.state.fontSize }} value='Some Text Here' />
                <Button onPress={() => this.setState({ color: '#0000ff', fontSize: 28, })} title="Blue" />
                <Button onPress={() => this.setState({ color: '#ff0000', fontSize: 28.05 })} title="Red" />
            </View>
        )
    }
}

@DiMaNacho
Copy link

DiMaNacho commented Nov 22, 2017

original:

fontSize: 16

after event:

fontSize: 16.05

x.05 is the minimum value you need to force the color update.

@hramos hramos added the Platform: iOS iOS applications. label Mar 8, 2018
@react-native-bot react-native-bot added Ran Commands One of our bots successfully processed a command. Component: TextInput Related to the TextInput component. labels Mar 16, 2018
@stale
Copy link

stale bot commented Jun 14, 2018

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.

@stale stale bot added the Stale There has been a lack of activity on this issue and it may be closed soon. label Jun 14, 2018
@stale
Copy link

stale bot commented Jul 14, 2018

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jul 14, 2018
@facebook facebook locked as resolved and limited conversation to collaborators Jul 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: TextInput Related to the TextInput component. Platform: iOS iOS applications. Ran Commands One of our bots successfully processed a command. Stale There has been a lack of activity on this issue and it may be closed soon.
Projects
None yet
Development

No branches or pull requests

6 participants