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

Make debounce specific to the instance #49

Closed

Conversation

sslotsky
Copy link

@sslotsky sslotsky commented May 2, 2016

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 same debounce 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.

@@ -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" />
Copy link
Author

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.

@sslotsky
Copy link
Author

Any chance of getting a review on this?

attaboy added a commit to ellipsis-ai/ellipsis that referenced this pull request May 30, 2016
NB: patch applied from JedWatson/react-codemirror#49 which
has not yet been accepted into the project.
@attaboy
Copy link

attaboy commented May 30, 2016

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.

@nm2501
Copy link

nm2501 commented Jun 22, 2016

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

obrok added a commit to Aircloak/aircloak that referenced this pull request Jul 1, 2016
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.
@sslotsky
Copy link
Author

@JedWatson Any chance of getting this PR reviewed?

@erik-sn
Copy link

erik-sn commented Jul 25, 2016

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.

@veeramarni
Copy link

veeramarni commented Jul 31, 2016

I agree with @sslotsky the ref string attribute is gone in version 0.15.0 and you need to use ref callbackup attribute.

check here

In render function

        return (
            <div className={editorClassName}>
                <textarea ref={(ref) => this.textarea = ref} name={this.props.path} defaultValue={this.props.value} autoComplete="off" />
            </div>
        );

in ComponentDidMount

 componentDidMount () {
        const textareaNode = this.textarea;

@tonyonodi
Copy link

I was having the same problem where the value wouldn't update as @nm2501 and this fix worked for me too.

Thanks @sslotsky

@rgbkrk
Copy link

rgbkrk commented Sep 14, 2016

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.

@sslotsky
Copy link
Author

@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.

@JedWatson
Copy link
Owner

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.

@sslotsky
Copy link
Author

@JedWatson Sure I'd be glad to rebase it. Would you also like me to undo the changes to lib? It occurs to me that you probably just compile before publishing, and that's why my lib changes included things that I hadn't touched in src.

@sslotsky
Copy link
Author

Closing in favor of #68

@sslotsky sslotsky closed this Sep 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants