materiahq / ngx-monaco-editor

Monaco Editor Library for Angular v6 and above
MIT License
159 stars 35 forks source link

parsedError can be undefined #50

Open olegkap opened 3 years ago

olegkap commented 3 years ago

Hi,

When form with editor is loaded form is marked as dirty. I did some research and found that in registerEditorListenersmethod variable hasValidationStatusChangedwill resolve to true when control initialized and no changes were made. This is due to the fact that this.parsedError resolves to undefined and currentParsedErroris '' so following line will resolve to true: const hasValidationStatusChanged = this.parsedError !== currentParsedError;

This causing control to be flagged as modified and when its part of FormGroup it marks the whole form as dirty.

I am using ngx-monaco-editor as follow: <ngx-monaco-editor [options]="editorOptions" formControlName="queryText" (init)="editorInit($event)"></ngx-monaco-editor>

Is there work around or its by design?

Thanks, Oleg

etay-schur-apolicy commented 3 years ago

+1 This is also happening to me every time onMouseLeave event fired any suggestions?

jmarc-roy commented 3 years ago

Hi @etay-schur-apolicy,

Sorry for the late reply. I don't face this issue, when trying to reproduce with angular v12 and latest library version v5.1.0. Here is a stackblitz link showing the actual behavior: https://stackblitz.com/edit/angular-ogp6rc.

If you still face this issue, please kindly share a reproduction of the bug.

olegkap commented 3 years ago

Hi Geo,

Thanks for looking into it.

I just upgraded to Angular 12 and still facing the issue. (Will try to create reproduceable example later)

I did noticed interesting behavior that occasionally this error doesn't occur in some cases, I think it has to do with text size or some other factor, still trying to figure it out. Maybe if parsedError would be initialized to '' then error would go away, since eventually it set to '' anyway as initial state?

parsedError: string = '';

Thanks, Oleg