refresh editor value when config is updated (#11559)

This commit is contained in:
Josh Hawkins 2024-05-27 10:31:58 -05:00 committed by GitHub
parent eca8c52f15
commit c07f6999ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -29,7 +29,7 @@ function ConfigEditor() {
const [error, setError] = useState<string | undefined>();
const editorRef = useRef<monaco.editor.IStandaloneCodeEditor | null>(null);
const modelRef = useRef<monaco.editor.IEditorModel | null>(null);
const modelRef = useRef<monaco.editor.ITextModel | null>(null);
const configRef = useRef<HTMLDivElement | null>(null);
const onHandleSaveConfig = useCallback(
@ -124,6 +124,12 @@ function ConfigEditor() {
};
});
useEffect(() => {
if (config && modelRef.current) {
modelRef.current.setValue(config);
}
}, [config]);
if (!config) {
return <ActivityIndicator />;
}