kolkov / angular-editor

A simple native WYSIWYG editor component for Angular 6 -14+
https://angular-editor.kolkov.ru
MIT License
675 stars 361 forks source link

can the change detector run when AeSelectComponent (ControlValueAccessor ) writeValue adjust the value #341

Open jcompagner opened 3 years ago

jcompagner commented 3 years ago

see the image: image

the value is set through the AeSelectComponent (ControlValueAccessor writeValue) But it seems NgModel doesn't then check again for a change when it does that So i always see first the first option (Arial or Heading 1) instead of the actual selected (New Times Roman and default) they change at the moment i move my mouse over the component because then some event is triggering the change detection

Problem is that our application is fully "OnPush" so at some points "detechtChanges()" need to be called mostly when properties are changed in promises or timeouts. But it seems also in this scenario..

jcompagner commented 3 years ago

i think this is all caused because of the redirection writeValue of the ControlValueAccessor does not really write a value but just sets up something to be written..

in our component that wraps the editor we do this in the ngOnInit:

setTimeout(() => { this.cdRef.detectChanges(); }, 50);

then it kind of works
it still not so nice because you still see that going from Arial to New Times Roman and "Heading 1" -> "default" very quickly it doesn't show the right values directly