Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Redundant initial formControl valueChanges emit from quill-editor #1547

Closed
yuwu9145 opened this issue Jun 2, 2022 · 10 comments
Closed

Redundant initial formControl valueChanges emit from quill-editor #1547

yuwu9145 opened this issue Jun 2, 2022 · 10 comments

Comments

@yuwu9145
Copy link

yuwu9145 commented Jun 2, 2022

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
@yuwu9145 yuwu9145 changed the title redundant initial formControl valueChanges emit from quill-editor Redundant initial formControl valueChanges emit from quill-editor Jun 2, 2022
@KillerCodeMonkey
Copy link
Owner

feel free to contribute and send me a pr :)

@KillerCodeMonkey
Copy link
Owner

KillerCodeMonkey commented Jun 2, 2022

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

@IsaacSomething
Copy link

Maybe skip(1) to mimic angular valueChanges

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

@KillerCodeMonkey
Copy link
Owner

KillerCodeMonkey commented Oct 13, 2023

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

@imaliouris
Copy link

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...

@KillerCodeMonkey
Copy link
Owner

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

@imaliouris
Copy link

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..

@KillerCodeMonkey
Copy link
Owner

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

@KillerCodeMonkey
Copy link
Owner

I added a hint to the readme about that issue:
https://github.com/KillerCodeMonkey/ngx-quill?tab=readme-ov-file#known-issues

@titusfx
Copy link

titusfx commented May 12, 2024

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

Could you provide the lines where is trigger ( so we can try help the project, starting from there)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants