-
Notifications
You must be signed in to change notification settings - Fork 263
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
Make debounce specific to the instance #49
Conversation
@@ -79,7 +82,7 @@ const CodeMirror = React.createClass({ | |||
); | |||
return ( | |||
<div className={editorClassName}> | |||
<textarea ref="textarea" name={this.props.path} defaultValue={this.props.value} autoComplete="off" /> | |||
<textarea ref={(node) => this.textarea = node} name={this.props.path} defaultValue={this.props.value} autoComplete="off" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also mention this. My app did not complain about ref="textarea"
when I was using the npm package, but as soon as I ran npm link
to my local copy, I started getting the "Only a ReactOwner can have refs" issue. My understanding is that this way of using refs is preferred anyway so hopefully it's not a problem to make this change.
Any chance of getting a review on this? |
NB: patch applied from JedWatson/react-codemirror#49 which has not yet been accepted into the project.
Just a note that I've also stumbled on issues caused by #47 too — my first instance of CodeMirror on a page doesn't keep its options in sync with state when there is another instance on the page too. This pull request solves the problem for me. |
I can vouch for this PR too. I have several Codemirrors on the same page and modifying the 'value' (i.e. the code within the textarea) was only working for the bottom instance. With this PR, it works for all instances. Thanks @sslotsky |
The PR in question is JedWatson/react-codemirror#49. In our case it causes multiple pending queries to display the same statement despite being different.
@JedWatson Any chance of getting this PR reviewed? |
This also fixed an issue I was having with redux state not updating multiple mirrors. Thank you @sslotsky - @JedWatson you should consider merging this one. |
I agree with @sslotsky the check here In render function
in ComponentDidMount
|
Hey @sslotsky would it be worth rebasing this? @JedWatson I'm more than happy to help steward maintenance here as are other folks in the PRs. Let us know if there's a way to resolve (or even close!) these PRs. |
@rgbkrk I'd be happy to rebase it but I'd be even happier if I had some indication that @JedWatson is aware of this PR. |
Sorry for the delay on this - I totally missed it (!) Looks good, would be very happy to merge it if you don't mind rebasing @sslotsky. |
@JedWatson Sure I'd be glad to rebase it. Would you also like me to undo the changes to |
Closing in favor of #68 |
Solution to #47, ensures that the
debounce
is applied at the instance level. The way it is currently written, all instances of this component are sharing the samedebounce
so only one instance will update when multiple instances on a page are supposed to update simultaneously. This is an issue for things like drag & drop sorting of codemirror content blocks.