react-quill icon indicating copy to clipboard operation
react-quill copied to clipboard

BUG: Overwriting binding of key tab

Open tyzion opened this issue 2 years ago • 6 comments

Hi,

I'm using version beta.4 with react version 17.0.2.

I'm trying to override the tab function as shown in the Quill docs, and as mentioned in lots of threads: keyboard: { bindings: { // This will overwrite the default binding also named 'tab' tab: { key: 9, handler: function() { // Handle tab } }, } }

What happens is that if I press anything other than the key tab, the editor will break and disappear.

And then if I go around my app, it gives me this error:

TypeError: Cannot read properties of undefined (reading 'delta') ReactQuill.componentDidUpdate src/src/index.tsx:277 274 | // The component has been regenerated, so it must be re-instantiated, and 275 | // its content must be restored to the previous values from the snapshot. 276 | if (this.state.generation !== prevState.generation) {

277 | const {delta, selection} = this.regenerationSnapshot!; | ^ 278 | delete this.regenerationSnapshot; 279 | this.instantiateEditor(); 280 | const editor = this.editor!;

I've tried to debug, but couldn't find any answer as to why it happens.

Thanks

tyzion avatar Oct 07 '22 07:10 tyzion

It seems the problem comes from the setState() inside the onChange function of ReactQuill component If I comment the setState, the editor works without any errors

tyzion avatar Oct 13 '22 12:10 tyzion

I've got the exact same error (TypeError: Cannot read properties of undefined (reading 'delta')), but not because of the same reason - I'm using the quill-mention plugin and when I change it's config value (from the modules prop), I get that error

BenJeau avatar Oct 17 '22 17:10 BenJeau

Update:

Before I said that the editor without the setState worked seamlessly, but that's not true. It still is disappearing if I try to overwrite the "tab" function.

tyzion avatar Nov 17 '22 10:11 tyzion

Any help here? I'm having the same issue and I don't know how to solve it :/

aperezgarcia93 avatar Nov 08 '23 00:11 aperezgarcia93

Same error here, anyone able to solve it?

boradakash avatar Jun 05 '24 11:06 boradakash