minimalcomps-openfl icon indicating copy to clipboard operation
minimalcomps-openfl copied to clipboard

Fix ComboBox bug

Open freem-trg opened this issue 8 years ago • 6 comments

Current implementation create ComboBox that contains List of ListItems wich data is ListItem too. I think this is just a typo.

freem-trg avatar Aug 07 '17 07:08 freem-trg

@freem-trg Hi, thanks for the pull request.

MinimalComps documentation does state that a List contains:

strings or objects with label property

Is that your use case? You are attempting to pass String or Dynamic object with label property instead of ListItem?

jasonsturges avatar Aug 07 '17 14:08 jasonsturges

Yes. I want to use it with Array<String> or Array<EnumValue>. But signature of the class constructor and items setter want items:Array<ListItem>. And there is no way to pass Array<String> as in the documentation.

I've tried to create this array manually. But after that ComboBox shows something like this:

Select item: [+] [item ListItem] [item ListItem] ...

The problem is that ComboBox passed the _items to the List component. And List create its own ListItems (see List:111) and after it set passed _items as data (see List:128). After this ListItem casts his data to String.

freem-trg avatar Aug 07 '17 14:08 freem-trg

That seems strange - have you compared your implementation to the MinimalComps Designer project?

_comboBox.defaultLabel = "Default label";
_comboBox.addItem({label: "Item 1"});
_comboBox.addItem({label: "Item 2"});
_comboBox.addItem({label: "Item 3"});

jasonsturges avatar Aug 07 '17 15:08 jasonsturges

Hm, i missed this method. I'm sure it will work, because it is calls _list.addItem(item); directly. But if i want to pass my items via constructor args or items setter i will have problems because they take items:Array<ListItem>. My PR fix this case.

freem-trg avatar Aug 07 '17 15:08 freem-trg

This makes sense from the constructor, but I'm not sure I like the private internal data structure set to dynamic. Let me think about this, and prototype these changes.

jasonsturges avatar Aug 07 '17 17:08 jasonsturges

Yes, i'm usually avoid of using Dynamic too. Another way is to remove items argument from constructor and don't keep this data in ComboBox: private var _items and use ComboBox.addItem instead of it. I think it can be good solution too.

freem-trg avatar Aug 08 '17 07:08 freem-trg