Use sort option in FieldImages to sort the options after showing the editor (not before) (#482)

This commit is contained in:
Sam El-Husseini 2018-04-10 11:51:08 -07:00 committed by GitHub
parent 379a6a26be
commit 8f211a5c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,7 +2,7 @@
/// <reference path="../node_modules/pxt-core/built/pxtblocks.d.ts"/> /// <reference path="../node_modules/pxt-core/built/pxtblocks.d.ts"/>
/// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/> /// <reference path="../node_modules/pxt-core/built/pxtsim.d.ts"/>
export interface FieldPortsOptions extends Blockly.FieldCustomDropdownOptions { export interface FieldPortsOptions extends pxtblockly.FieldImagesOptions {
columns?: string; columns?: string;
width?: string; width?: string;
} }
@ -11,7 +11,7 @@ export class FieldPorts extends pxtblockly.FieldImages implements Blockly.FieldC
public isFieldCustom_ = true; public isFieldCustom_ = true;
constructor(text: string, options: FieldPortsOptions, validator?: Function) { constructor(text: string, options: FieldPortsOptions, validator?: Function) {
super(text, options, validator); super(text, { sort: true, data: options.data }, validator);
this.columns_ = parseInt(options.columns) || 4; this.columns_ = parseInt(options.columns) || 4;
this.width_ = parseInt(options.width) || 300; this.width_ = parseInt(options.width) || 300;
@ -24,11 +24,6 @@ export class FieldPorts extends pxtblockly.FieldImages implements Blockly.FieldC
trimOptions_() { trimOptions_() {
} }
getOptions() {
const options = super.getOptions();
return options ? options.sort() : undefined;
}
protected buttonClick_ = function (e: any) { protected buttonClick_ = function (e: any) {
let value = e.target.getAttribute('data-value'); let value = e.target.getAttribute('data-value');
this.setValue(value); this.setValue(value);