KillerCodeMonkey / ngx-quill

Angular (>=2) components for the Quill Rich Text Editor

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Redundant initial formControl valueChanges emit from quill-editor

yuwu9145 opened this issue · comments

When using [formControl] to <quill-editor>, it emit the default value through valueChanges observable.

This behaviour is inconsistent with the default Angular reactive form (no initial value emit but only emits when there are user changes)

Steps to reproduce

  1. Open demo link
  2. Open developer tool
  3. The default value can been found in console log
  4. By comparing the default Angular reactive form behaviour (found from this link). There is no initial value in console log

feel free to contribute and send me a pr :)

sadly i have no solution for that. This change is triggered, because i try to keep validators in sync after the quill editor is initialized. So the control/model does have the correct valid state and classes.

Seems like this triggers a change

Maybe skip(1) to mimic angular valueChanges

this.profileForm.valueChanges
    .pipe(skip(1))
    .subscribe((value) => console.log(value));

@IsaacSomething and maybe check if the model/control is marked as touched and reset it, if needed

I have the same problem, is there any update on this? I mean why would you emit valuechanges when nothing has changed? I have a formControl that has the default value and when I pass it to the quill editor it emits the same value...

like described by IsaacSomething use the rxjs operator "skip" to ignore the first trigger.

Thats not the proper way.. I have a formGroup that I track its changes and I dont always have a quill editor, or I may have more than one, so I can't just skip the first value.. Furthermore its not good for developer experience as it's not clear why this skip happens..

you can try to solve the issue and send a pr. but as i described above i have not idea how to solve it without breaking other functionality