From 8f211a5c19d420b0f2423b4792e9b3ed6aedb439 Mon Sep 17 00:00:00 2001
From: Sam El-Husseini <16690124+samelhusseini@users.noreply.github.com>
Date: Tue, 10 Apr 2018 11:51:08 -0700
Subject: [PATCH] Use sort option in FieldImages to sort the options after
showing the editor (not before) (#482)
---
editor/field_ports.ts | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/editor/field_ports.ts b/editor/field_ports.ts
index 53778ecf..8131c446 100644
--- a/editor/field_ports.ts
+++ b/editor/field_ports.ts
@@ -2,7 +2,7 @@
///
///
-export interface FieldPortsOptions extends Blockly.FieldCustomDropdownOptions {
+export interface FieldPortsOptions extends pxtblockly.FieldImagesOptions {
columns?: string;
width?: string;
}
@@ -11,7 +11,7 @@ export class FieldPorts extends pxtblockly.FieldImages implements Blockly.FieldC
public isFieldCustom_ = true;
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.width_ = parseInt(options.width) || 300;
@@ -24,11 +24,6 @@ export class FieldPorts extends pxtblockly.FieldImages implements Blockly.FieldC
trimOptions_() {
}
- getOptions() {
- const options = super.getOptions();
- return options ? options.sort() : undefined;
- }
-
protected buttonClick_ = function (e: any) {
let value = e.target.getAttribute('data-value');
this.setValue(value);