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.

Issue with multiple, successive instances

See original GitHub issue

When creating multiple instances of the slate Editor, one after the other, the additional instances are non-editable. Instead, when you try to focus them, they focus the original instance instead. (I have tested this issue in Safari and Chrome)

I have created a fiddle that reproduces this issue: https://jsfiddle.net/rossfishkind/yhzgjj82/35/

To reproduce in the fiddle:

  1. Tap the “Add Editor Instance” button to add the first instance.
  2. Once the instance appears, type some text into the editor.
  3. Now, tap the “Add Editor Instance” button again.
  4. Try to focus the new instance or enter text.

You will notice that it doesn’t work. It keeps focusing the first instance of the editor instead of the one you are selecting.

For what it’s worth, within my actual code, if you were to refresh the page after having created the instances, you can edit them normally, the issue only occurs if creating them successively without a refresh or un-mounting and mounting the parent component.

Any help would be much appreciated 😃

Thank you!

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
pizncommented, Mar 9, 2018

Because you use the same initialValue for every instances, and the Editor instances will use the document key for selection target.

Now you have two way to fixed this question:

  1. When you insert a new editor, you can change the document’s key value, like this:
const initialValue = () => Value.fromJSON({
  document: {
    key: `${+(new Date())}`,,
    nodes: [
      {
        kind: 'block',
        type: 'paragraph',
        nodes: [
          {
            kind: 'text',
            leaves: [{ text: '' }]
          }
        ]
      }
    ]
  }
})
...
increment = () => {
  	const editors = [...this.state.editors, { content: initialValue() }];
  	this.setState({
    	editors,
    });
  }
  1. Use resetKeyGenerator and setKeyGenerator to change the default key.
3reactions
rossfishkindcommented, May 1, 2018

@oyeanuj I used resetKeyGenerator within componentDidMount in the parent component that wrapped my slate instances together, and I used setKeyGenerator on initialization of my app like so:

setKeyGenerator(() => rand());

where my rand() function returns a random alphanumeric string to associate with any slate instances. Hope that helps!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple Instance Classification via Successive ... - Minds@UW
Abstract. The multiple instance classification problem [6,2,12] is formulated using a linear or nonlinear kernel as the minimization of a linear function in ......
Read more >
Multiple Instance Classification via Successive ... - Springer Link
A distinguishing aspect of our linear classifier not shared by other multiple instance classifiers is the sparse number of features it utilizes.
Read more >
Multiple comparisons problem - Wikipedia
In statistics, the multiple comparisons, multiplicity or multiple testing problem occurs when one considers a set of statistical inferences simultaneously ...
Read more >
Solving the multiple instance problem with axis ... - ICS, UCI
The multiple instance problem arises in tasks where the training examples are ambiguous: a single example object may have many alternative feature vectors...
Read more >
The problem with unadjusted multiple and sequential ... - Nature
The problem with multiple statistical testing is more often ... When, for instance, performing 10 independent tests, whilst H0 is true, ...
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