MonacoEditorReactComp not fires onTextChanged callback if you change code resource
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:
https://github.com/TypeFox/monaco-languageclient/assets/24254622/db412849-45a4-475b-a38c-a141079c65a7
HI @lobotomoe thank you for reporting this and providing a re-producible example. We will investigate...
@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?
@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
@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
@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...
@lobotomoe can you try the latest preview build: https://www.npmjs.com/package/@typefox/monaco-editor-react/v/6.0.0-next.5 ?
v6 is available. No feedback was provided. No longer considered an issue.