Skip to content

Commit 5d45fbc

Browse files
authored
create sprite kinds during field validation (#10908) (#10917)
1 parent 265fb17 commit 5d45fbc

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

pxtblocks/fields/field_kind.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,13 @@ export class FieldKind extends FieldDropdown {
8282
}
8383

8484
doClassValidation_(value: any) {
85+
if (typeof value === "string" && this.sourceBlock_?.workspace) {
86+
const existing = getExistingKindMembers(this.sourceBlock_.workspace, this.opts.name);
87+
if (!existing.some(e => e === value)) {
88+
createVariableForKind(this.sourceBlock_.workspace, this.opts, value);
89+
}
90+
}
91+
8592
// update cached option list when adding a new kind
8693
if (this.opts?.initialMembers && !this.opts.initialMembers.find(el => el == value)) this.getOptions();
8794
return super.doClassValidation_(value);

0 commit comments

Comments
 (0)