PeterStaev / NativeScript-Drop-Down

A NativeScript DropDown widget.
Apache License 2.0
105 stars 65 forks source link

Dropdown rendering certain items as blank if selectedIndex manipulated outside #169

Closed shyamseshadri closed 6 years ago

shyamseshadri commented 6 years ago

Happening in a NG + Nativescript App. Only tested on Android.

Seeing cases where if the selectedIndex is manipulated outside the dropdown (via Angular bindings), then the dropdown items disappear.

Have a base repro case for this at https://github.com/shyamseshadri/nativescript-dropdown-bugrepro

Used the basic Nativescript + Ng template.

shyamseshadri commented 6 years ago

Checked the other issues, (https://github.com/PeterStaev/NativeScript-Drop-Down/issues/163), this is happening even when it is not in a TabView

shyamseshadri commented 6 years ago

@PeterStaev debugged this a bit more, from what I can make out, the following is happening:

    public _getRealizedView(convertView: android.view.View, realizedViewType: RealizedViewType): View {
      if (convertView) {
            let layout = this._realizedItems[realizedViewType].get(convertView);
            if (layout) {
                return layout;
            }
            convertView = null;
        }
     if (!convertView) {
       // Same as before

Again, not sure of the implication of making this change though...

PeterStaev commented 6 years ago

Hey @shyamseshadri , thanks for looking into this. Seems the problem is with this line: https://github.com/PeterStaev/NativeScript-Drop-Down/blob/master/drop-down.android.ts#L463

Last time I checked for some reason the Spinner never reused views. So this ended up making the _realizedItems full of views that were not getting disposed but also were not used. I have to debug this a bit more and see what would be the best way to handle this.

shyamseshadri commented 6 years ago

Super, sounds good. I'm going to use my hack locally in the meantime to create my builds so its not a stopper, let me know if I can help in anyway