question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to force clear input after sending message ?

See original GitHub issue

I’m facing a problem with android.

Each time i send a message the input seems to be cleared but when i start typing again the previous value is merged to the new value.

Ex : if i want to send 2 messages “Hello” and “World”

first i send “Hello” then when i start to write “World” my input display “HelloW” so the value of the last send is merged to the new value.

This happend only on android. i’ve tried to manually manage by affecting the value of onInputTextChanged to text props and then clear it at each send but it doesn’t fix it.

Any suggestion ?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:14
  • Comments:19

github_iconTop GitHub Comments

10reactions
zachrnolancommented, Mar 30, 2018

Found a workaround. I have two different Galaxy S7’s and one of them had autosuggest/correct on by default. That phone was the one having this issue. I forced autoCorrect off in Gifted Chat and this issue went away.

Just add this prop to your GitftedChat component:

textInputProps={{
    autoCorrect: false
}}
6reactions
richardmillen94commented, Aug 1, 2018

A dirty workaround for this that I’m currently using is setting the autoCorrect prop to false and then true again onSend (only for Android devices).

state = {
    messages: [],
    androidAutoCorrectFix: true,
}

onSend(messages = []) {
    this.setState(
        previousState => ({
            messages: GiftedChat.append(previousState.messages, messages),
            androidAutoCorrectFix: Platform.OS !== 'android'
        }),
        Platform.OS === 'android' && (() => this.setState({androidAutoCorrectFix: true}))
    )
}

render() {
    return (
        <GiftedChat
            textInputProps={{
                autoCorrect: Platform.OS === 'ios' || this.state.androidAutoCorrectFix
            }}
            messages={this.state.messages}
            onSend={messages => this.onSend(messages)}
            user={{
                _id: 1
            }}
        />
    )
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Clearing my form inputs after submission - Stack Overflow
I just want my text inputs and textarea to clear after I hit the submit button. Here's the code. AFAIK, your <form> is...
Read more >
How To Clear Input Field on Focus - W3Schools
Learn how to clear an input field on focus. Click on the input field to clear it: Clear Input Field on Focus. Example....
Read more >
Clear Input fields after Submit using JavaScript | bobbyhadz
Clear multiple input fields after submit # · Use the querySelectorAll() method to select the collection. · Use the forEach() method to iterate...
Read more >
<input type="reset"> - HTML: HyperText Markup Language
Try entering some text into the text field, and then pressing the reset button. Adding a reset keyboard shortcut. To add a keyboard...
Read more >
How to Clear Input Values of Dynamic Form in React
There's a lot to consider when working on a React application, especially when they involve forms. Even if you're able to create a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found