Closed diogeneshamilton closed 5 years ago
Here's the workaround by the way (which basically copies code from the component's internal code):
let newValue = this.state.enseTitle + "#"
this.setState({ enseTitle: newValue })
var e = new CustomEvent('change', { bubbles: true })
this.textarea.value = newValue;
this.textarea.dispatchEvent(e);
this.rta._changeHandler(e);
I see! Nice use case, I will take a look on it. It makes sense to support this. 🙌
Hey @diogeneshamilton this has been deployed as 3.1.5! It would be awesome if you can test it, I did some chore, so I hope everything works as it should. 🙏
You can check the playground, I've added also test for that (https://github.com/webscopeio/react-textarea-autocomplete/pull/110) 💪
Amazing thank you! I will test.
I am using the component and when I change the value (by changing my component's state), the _changeHandler does not trigger. It does trigger getDerivedStateFromProps, but not _changeHandler.
This is problematic since I'd like to offer a button to trigger autocomplete (like Twitter, press @ button and with minChar=0 it shows suggestions).
Right now I have a workaround by defining a CustomEvent and then calling _changeHandler(e) on this.rta, however I would imagine this should just work out of the box. Thoughts?