Skip to content

Commit

Permalink
Update field_userenum.ts
Browse files Browse the repository at this point in the history
Data binding fails.
microsoft#9653

Console warning:
Cannot set the dropdown's value to an unavailable option.
Block type: radioMessageCode, Field name: MEMBER, Value: add1
  • Loading branch information
jp-96 authored Aug 24, 2023
1 parent ca97bf3 commit d10a909
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion pxtblocks/fields/field_userenum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ namespace pxtblockly {
}

doClassValidation_(value: any) {
// The format of the name is 10mem where "10" is the value and "mem" is the enum member
if (this.sourceBlock_ && this.sourceBlock_.workspace) {
const options = this.sourceBlock_.workspace.getVariablesOfType(this.opts.name);
options.some(model => {
const [name, ] = parseName(model);
if (name == value) {
value = model.name
return true
}
return false
});
}
// update cached option list when adding a new kind
if (this.opts?.initialMembers && !this.opts.initialMembers.find(el => el == value)) this.getOptions();
return super.doClassValidation_(value);
Expand Down Expand Up @@ -169,4 +181,4 @@ namespace pxtblockly {
}
return undefined;
}
}
}

0 comments on commit d10a909

Please sign in to comment.