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

Fix lagging issues when using two way data bind #326

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

dkarkanas
Copy link

When we are using json schema form with the following sytnax, we realized the UI was lagging because of an infinite loop triggered/triggering ngOnChanges.

<json-schema-form
                    [schema]="schema"
                    [(data)]="data"
                    [layout]="layout"
                    [framework]="framework"
                    [options]="jsonFormOptions"
                    [widgets]="widgets"
                    (onChanges)="onFormChanges($event)"
                    (isValid)="isValid($event)"
                    (onSubmit)="onSubmit($event)">
</json-schema-form>

Adding a condition for checking the equality of previous and current value, fixes the infinite loop.

if (changes.data && isEqual(changes.data.previousValue, changes.data.currentValue)) {      
      return;
}

@netlify
Copy link

netlify bot commented Aug 11, 2022

Deploy Preview for ajsf ready!

Name Link
🔨 Latest commit 89de387
🔍 Latest deploy log https://app.netlify.com/sites/ajsf/deploys/62f4bdaa5fab3d0008ee0185
😎 Deploy Preview https://deploy-preview-326--ajsf.netlify.app/
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@dkarkanas dkarkanas marked this pull request as draft August 11, 2022 08:30
@dkarkanas dkarkanas marked this pull request as ready for review August 11, 2022 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant