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

Introduce the dataChangeEventDisabled property #143

Closed
wants to merge 4 commits into from

Conversation

Ruud-cb
Copy link

@Ruud-cb Ruud-cb commented Oct 9, 2019

Suggested merge commit message (convention)

Feature: Introduced the dataChangeEventDisabled property that will enable performance boost for large documents. Closes #141.


Additional information

For example – encountered issues, assumptions you had to make, other affected tickets, etc.

@oleq
Copy link
Member

oleq commented Oct 10, 2019

Hi, @Ruud-cb! Can you tell us more about what problem does this PR actually solve? Some use–case or maybe a demo?

@Ruud-cb
Copy link
Author

Ruud-cb commented Oct 10, 2019

Hi @oleq, follow the reproduction steps in the issue, use the demo-form component. You will notice extreme lag after inserting a lot of text. Then change public disabledOnChangeEvent: boolean = false; to true. The lag during typing/pasting text is solved. Still lag noticeable during leaving the textbox unfortunately, but at some point the new data has to be sent to ngModel.

@ma2ciek
Copy link
Contributor

ma2ciek commented Oct 15, 2019

Thanks @Ruud-cb for the PR.

The lag during typing/pasting text is solved. Still lag noticeable during leaving the textbox unfortunately, but at some point the new data has to be sent to ngModel.

It's something we can do nothing about, the editor.getData() must be called at some point. However, I'd change the property name to something like muteDataChangeEvent, as it touches both, the [(ngModel)]'s control value accessor and the <ckeditor (change)>. Also, could you write a test for this change?

Copy link
Contributor

@ma2ciek ma2ciek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some necessary changes are described in the above post.

@ma2ciek
Copy link
Contributor

ma2ciek commented Oct 15, 2019

I could not find a way to get the text manually since Editor.getData() does not exist, so I execute cvaOnChange when the text editor blurs.

What do you mean? you can get the data with editor.getData().

@Ruud-cb
Copy link
Author

Ruud-cb commented Oct 15, 2019

Thanks @Ruud-cb for the PR.

The lag during typing/pasting text is solved. Still lag noticeable during leaving the textbox unfortunately, but at some point the new data has to be sent to ngModel.

It's something we can do nothing about, the editor.getData() must be called at some point. However, I'd change the property name to something like muteDataChangeEvent, as it touches both, the [(ngModel)]'s control value accessor and the <ckeditor (change)>. Also, could you write a test for this change?

I understand that editor.getData() must be called at some point, no problem for me that this happens on blur, it doesn't happen during typing which is great.

I could not find a way to get the text manually since Editor.getData() does not exist, so I execute cvaOnChange when the text editor blurs.

What do you mean? you can get the data with editor.getData().

Sorry for the confusion, Editor.getData() was used in the demo component (or whichever component uses the ckeditor component). As far as I found that doesn't exist. As you commented on my code, indeed that does not exist on the class constructor. I forgot to delete it again because it's now not needed anymore in onSubmit() because (blur) will occur before the user clicks on onSubmit(), right?

It would be favorable if you can adjust the unit tests as it will take you significant less time.

@ma2ciek ma2ciek changed the title On change disable Introduce the dataChangeEventDisabled property that will enable performance boost for large documents Oct 15, 2019
@ma2ciek ma2ciek changed the title Introduce the dataChangeEventDisabled property that will enable performance boost for large documents Introduce the dataChangeEventDisabled property Oct 15, 2019
@ma2ciek
Copy link
Contributor

ma2ciek commented Oct 15, 2019

After a while I think about this, such change can be dangerous for big documents as they might be not saved for a long time, as now the saving is done only during the blur event. A debounce-based approach could be a better solution as this should work out of the box, without providing any unuseful properties. Although I'm not sure if that approach will work with Angular Reactive Forms too.

@Ruud-cb
Copy link
Author

Ruud-cb commented Oct 17, 2019

After a while I think about this, such change can be dangerous for big documents as they might be not saved for a long time, as now the saving is done only during the blur event. A debounce-based approach could be a better solution as this should work out of the box, without providing any unuseful properties. Although I'm not sure if that approach will work with Angular Reactive Forms too.

True, although it is deliberately set by the developer, so one should know. Currently the problem is that no text can be typed in big documents smoothly. And to solve the 'losing data' problem, I would suggest developers to make use of IComponentCanDeactivate, which can produce a warning when trying to reload, go back or exit the page. Of course this is beyond the scope of this project.

@ma2ciek
Copy link
Contributor

ma2ciek commented Oct 18, 2019

True, although it is deliberately set by the developer, so one should know. Currently the problem is that no text can be typed in big documents smoothly. And to solve the 'losing data' problem, I would suggest developers to make use of IComponentCanDeactivate, which can produce a warning when trying to reload, go back or exit the page. Of course this is beyond the scope of this project

But I think that using the debounce effect is safer and it should allow the same editing experience. This is a better approach than "I know it can be an unsafe feature, but I have big documents so I have no option."

@Ruud-cb
Copy link
Author

Ruud-cb commented Oct 18, 2019

Alright, that's also possible. Only argument against that is that it might occur the user starts typing again exactly at the moment the debounce is fired off. Maybe both, whatever you want :).

@tgv1975
Copy link

tgv1975 commented Nov 23, 2019

Hi @ma2ciek, the build is failing on this due to unit test coverage being under 100%, so your changes have not been merged, the large document problem was not solved.

@ma2ciek ma2ciek added this to the next milestone Nov 25, 2019
@pomek pomek removed this from the next milestone Nov 10, 2020
@ma2ciek
Copy link
Contributor

ma2ciek commented Jun 25, 2021

I think that this change is no longer required as the editor.getData() only happens in the 2-way binding and it's a must there - see:

modelDocument.on( 'change:data', ( evt: CKEditor5.EventInfo<'change:data'> ) => {
this.ngZone.run( () => {
if ( this.cvaOnChange && !this.isEditorSettingData ) {
const data = editor.getData();
this.cvaOnChange( data );
}
this.change.emit( { event: evt, editor } );
} );
} );

@ma2ciek ma2ciek closed this Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The component works slow on large documents
5 participants