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

MonacoEditorReactComp not fires onTextChanged callback if you change code resource #697

Open
lobotomoe opened this issue Jul 2, 2024 · 5 comments

Comments

@lobotomoe
Copy link

I try to use @typefox/monaco-editor-react with multiple files, but only for first file callback onTextChanged fired.

Repro repo: https://github.com/lobotomoe/monaco-on-text-changed-issue

Steps for repro:

  • git clone
  • npm i
  • npm run dev

Try to type something and you will see in console that onTextChanged fired. Switch to second file. Try to type — nothing happens. Switch back to first file, try to type — callback fires.

See video demo:

demo.mp4
@kaisalmen
Copy link
Collaborator

HI @lobotomoe thank you for reporting this and providing a re-producible example. We will investigate...

@kaisalmen
Copy link
Collaborator

@lobotomoe the file changes are not provoking componentDidUpdate in MonacoEditorReact . The whole evaluation internally is based on UserConfig comparison which decides if the underlying wrapper/editor needs to be restart or just reconfigured.
But there is no simple trigger. Currently, you can create a ref to -MonacoEditorReactComp and then trigger the update directly on the underlying wrapper.
Maybe we should add a boolean property to the MonacoEditorProps, so they can easily trigger a re-evaluation of the status?

@lobotomoe
Copy link
Author

@kaisalmen Thanks for the answer! I'm not sure if it's worth bothering so much purely because of my case, but I don't mind if there's a flag 😀

Currently I'll try your approach with ref and manual trigger

@kaisalmen
Copy link
Collaborator

@lobotomoe we want to transform the ClassComponent to a FunctionalComponent and when we will do it think about this use case.
Another possibility I forgot about is that onLoad() gives you the wrapper and when you have that you can do everything, see: https://github.com/TypeFox/monaco-languageclient/blob/main/packages/examples/src/python/client/reactPython.tsx#L44-L46

@kaisalmen
Copy link
Collaborator

@lobotomoe #739 is merged, but not yet released. It will take some time because it will be a major version and there are other things that should be included as well.

I will take a look if we can build a unit test for this problem now...

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

No branches or pull requests

2 participants