Skip to content

Commit

Permalink
fix: Cleanup the default value for media field when used in lists. (#227
Browse files Browse the repository at this point in the history
)
  • Loading branch information
Zoramite committed Aug 12, 2021
1 parent 92fc14a commit b21762b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/ts/editor/field/media.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,25 @@ export class MediaField
};
}

/**
* Cleanup the media value.
*
* If the media field is used in a normal list it will have trouble
* determining a default empty value.
*
* @param value Original value from the source.
*/
cleanOriginalValue(value: any): any {
value = super.cleanOriginalValue(value);

// Default to object if original value is an empty string.
if (value === '') {
return {};
}

return value;
}

protected ensureGroup() {
if (!this.group && this.config.fields) {
this.group = this.types.fields.newFromKey(
Expand Down

0 comments on commit b21762b

Please sign in to comment.