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

Error: Calls to EditorView.update are not allowed while an update is in progress #280

Open
Yijx opened this issue Feb 24, 2022 · 7 comments
Labels
help wanted Extra attention is needed

Comments

@Yijx
Copy link

Yijx commented Feb 24, 2022

I set onBlur function on CodeMirror and change state (cursor is in edit box), at same time I use command+f to get a search box,CodeMirror will tell me 'Error: Calls to EditorView.update are not allowed while an update is in progress'.
I think it is update conflict?

You can use this demo
https://codesandbox.io/embed/react-codemirror-example-codemirror-6-forked-xx4qvz?fontsize=14&hidenavigation=1&theme=dark
image
image

@jaywcjlove
Copy link
Member

I didn't reproduce your error. @Yijx

@Yijx
Copy link
Author

Yijx commented Mar 21, 2022

I didn't reproduce your error. @Yijx

Hi,it still has error, let me list the detailed steps
first,enter the page,and wait for the page to load,
and,move the cursor in the textarea
last,press command+f or ctrl+f

Thanks for your help

@jaywcjlove
Copy link
Member

@jaywcjlove
Copy link
Member

@Yijx This may be a CM6 internal bug. I've released a new version that blocks the Ctrl+f shortcut.

But that didn't really solve the problem.

github-actions bot pushed a commit that referenced this issue Mar 27, 2022
@jaywcjlove
Copy link
Member

if (Array.isArray(basicSetup)) {
/**
* 🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧🚧
* This is not a solution.
* https://github.com/uiwjs/react-codemirror/issues/280
*/
basicSetup.map((item) => {
if (item.value && Array.isArray(item.value)) {
item.value = item.value
.map((keymap: any) => {
if ('Mod-f' === keymap.key) {
return undefined;
}
return keymap;
})
.filter(Boolean);
}
return item;
});
}

@Yijx This is a really bad way.

@jaywcjlove jaywcjlove added the help wanted Extra attention is needed label Mar 27, 2022
@jaywcjlove jaywcjlove pinned this issue Mar 28, 2022
jaywcjlove added a commit that referenced this issue Mar 28, 2022
github-actions bot pushed a commit that referenced this issue Mar 28, 2022
@jaywcjlove
Copy link
Member

https://codesandbox.io/embed/uiwjs-react-codemirror-issues-280-rw4zl7?fontsize=14&hidenavigation=1&theme=dark

@Yijx This is probably the best solution.

import React, { useEffect, useState } from "react";
import CodeMirror from "@uiw/react-codemirror";
import { javascript } from "@codemirror/lang-javascript";

export default function App() {
  const [a, setA] = useState(0);
  const [extensions, setextensions] = useState([]);
  useEffect(() => {
    setextensions([javascript({ jsx: true })]);
  }, []);
  return (
    <div>
      {a}
      <CodeMirror
        value="console.log('hello world!');"
        height="200px"
        extensions={extensions}
        onChange={(value, viewUpdate) => {
          console.log("value:", value);
        }}
        onBlur={() => setA(a + 1)}
      />
    </div>
  );
}

@lililo111
Copy link

https://codesandbox.io/embed/uiwjs-react-codemirror-issues-280-rw4zl7?fontsize=14&hidenavigation=1&theme=dark

@Yijx This is probably the best solution.

import React, { useEffect, useState } from "react";
import CodeMirror from "@uiw/react-codemirror";
import { javascript } from "@codemirror/lang-javascript";

export default function App() {
  const [a, setA] = useState(0);
  const [extensions, setextensions] = useState([]);
  useEffect(() => {
    setextensions([javascript({ jsx: true })]);
  }, []);
  return (
    <div>
      {a}
      <CodeMirror
        value="console.log('hello world!');"
        height="200px"
        extensions={extensions}
        onChange={(value, viewUpdate) => {
          console.log("value:", value);
        }}
        onBlur={() => setA(a + 1)}
      />
    </div>
  );
}

I have the same problem using '@uiw/react-codemirror' in version 4.7.0, when I try to setStae in 'onBlur'.
I don't know how this example help us to solve this problem.
How could I solve it now and if anyone could help will be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants