-
Notifications
You must be signed in to change notification settings - Fork 703
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
How can I, if possible, manually triggering resize for reactive loading #354
Comments
Not sure how you have things setup, but you'll want to exclude the textarea element from reactive updates (have shouldComponentUpdate return false) since React will replace the inline styles on the textarea element that Autosize is adding. Here's an example component of how I think it would work: export default class extends React.Component {
componentDidMount() {
autosize(this._el);
}
shouldComponentUpdate(nextProps, nextState) {
return false;
}
render() {
return <textarea ref={el => this._el = el} defaultValue={this.props.children || ''}/>
}
} |
My bad, I was using React as an example I wasn't sure if you would know how to do it using VueJS which is what I'm using for my project. Is there any method I can call to trigger resize? I tried using jQuerys |
Call |
I believe you can't use jQuery to trigger a native custom event (it has it's own internal events system that, and you can use trigger to fire a native event or a jQuery custom event). |
Beautiful. Thank you so much. |
I have the same issue with Vue, but can't fix it. #364 @ggJSC how did you fix it? I tried watch: {
propValue: function () {
this.textfieldValue = this.propValue
autosize.update(this.$refs.textarea)
}
} But this have 0 effect (with this function my data is setting to textarea, so I am trying to update textarea same time) |
I don't have experience with Vue, but my guess would be that you need to wait for the changed value to not just change, but for the change to be reflected in the DOM. I would try using the |
@jackmoore thanks for tip, I remembered watch: {
propValue: function () {
this.textfieldValue = this.propValue
this.$nextTick(function () {
autosize.update(this.$refs.textarea)
})
}
} |
If the
EDIT: As an addendum I'd like to add that I believe subsequent |
I'm using React and loading information into the text area. Is there a way I can force it to resize because when my page loads info for the first time, the text area is too small.
The text was updated successfully, but these errors were encountered: