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: improper cloning of custom fields #925

Merged
merged 5 commits into from
Feb 6, 2024

Conversation

shmishtopher
Copy link
Contributor

Fixes a bug where MetaObjectField passes custom fields into the constructor after calling clone, causing the editor to crash due to missing .get() methods on the custom fields.

Copy link
Contributor

@aarthificial aarthificial left a comment

Choose a reason for hiding this comment

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

I believe this.transform('get') should also include customFields, just like how serialize does.

@shmishtopher
Copy link
Contributor Author

I'm not sure how much sense it makes to include custom fields in the transform itself, given that any calls to get on custom fields would fail anyway. I added an override to the ObjectMetaField::get method in the latest commit as a workaround. Alternatively, we can return to your original implementation of ObjectMetaField::transform and add special handling to the ObjectMetaField constructor to fix the erroneous calls to get.

@aarthificial
Copy link
Contributor

Apologies for the confusion. I meant that the place where this.transform('get') is invoked (in the handleChange callback) should include customFields. This is where the value is calculated and so corresponding calls to get would return it too:

protected handleChange = () => {
  if (this.ignoreChange) return;
  this.value.current = {
    ...this.transform('get'),
    ...this.customFields,
  };
};

@aarthificial aarthificial merged commit 4981da7 into motion-canvas:main Feb 6, 2024
9 checks passed
@aarthificial
Copy link
Contributor

Awesome, thanks for the fix!

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

2 participants