angular-froala-wysiwyg icon indicating copy to clipboard operation
angular-froala-wysiwyg copied to clipboard

touched set on mousedown

Open StickNitro opened this issue 5 years ago • 3 comments

Have noticed a problem when using the Froala WYSIWYG Editor within a mat-form-field. When I use a <input matInput formControlName="formModel" /> in a mat-form-field with a required validator I see the error is set to { "required": true } and touched and invalid are false and true respectively. When clicking into the field nothing changes but when i leave the field the touched value gets updated to true.

When I use the Froala with <textarea matInput [froalaEditor] formControlName="formModel"></textarea> I see the same as above except when I click into the editor the touched value is updated to true and the form validation immediately shows to the user.

This should IMO be consistent with how the standard input etc. work and the touched value should be updated on blur

StickNitro avatar Nov 04 '19 17:11 StickNitro

Looking at the code, this (line 181 in editor.directive.ts)

this._editor.events.on('mousedown', function () {
        setTimeout(function () {
          self.onTouched();
        }, 0);
      });

This should be the blur event which would set touched when leaving the control, I could make this change and submit a PR if this makes sense

StickNitro avatar Nov 04 '19 17:11 StickNitro

I totally agree. The blur event would make more sense!

iiceman40 avatar Feb 26 '21 14:02 iiceman40

Is this still an issue?

lukebartlett97 avatar Dec 08 '21 16:12 lukebartlett97