PeterStaev / NativeScript-Drop-Down

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

Issue with routing and dropdown hint on IOS #80

Closed odubuc closed 7 years ago

odubuc commented 7 years ago

I'm using Nativescript-Drop-Down in an application using a page-router-outlet. If the dropdown is used on a page following a navigation, the hint of the dropdown will always be visible even if a value is selected.

I've created a small example to share the issue: https://github.com/odubuc/nativescript-sample/tree/master/issue-dropdown

When the app start, click on Dropdown, then the hint I am Groot! should not be visible. (The code sample of the dropdown was taken from your repo)

in main.ts, you can comment/uncomment to use or not the router to see how the dropdown react differently in both scenarios. I'd expect the dropdown to have the value selected in both case.

Am I doing something wrong or is this a bug? Thanks!

odubuc commented 7 years ago

I forgot to mention, this bug is only visible on IOS.

PeterStaev commented 7 years ago

Hey @odubuc , your sample project doesn't run on my end. I'm getting Unexpected value 'undefined' imported by the module 'MainModule'

Please check if you have committed everything. Also I see your project aims Angular 4.0 and the plugin has not been tested for 4.0. There is probably some event call sequence change. You can try to set the value for the index in the definition of the file and not in the ngOnInit. Hope this helps.

odubuc commented 7 years ago

Hi @PeterStaev, you are right, I did not meant to go for nativescript-angular 1.5.0, this was a last minute mistake in my sample, I fixed the dependence to 1.4.1. it should work properly now.

You can try to set the value for the index in the definition of the file and not in the ngOnInit.

even if I write public selectedIndex = 1; it will still display the hint and not the value. I'm open to other suggestions :)

odubuc commented 7 years ago

Hi @PeterStaev, Were you able to reproduce my issue using my sample?

PeterStaev commented 7 years ago

Hey @odubuc , sorry but I'm a bit swapped right now with other work, so I do not have much time to troubleshoot this 😢 Will let you know once I do.

odubuc commented 7 years ago

@PeterStaev no problem! I'm in the same situation so I understand, I'll give it a shot also it I ever get a minute. Thanks for the feedback :)

bradmartin commented 7 years ago

snip20170421_1

I'm working through this myself on plain NS app. Even using a timeout and the hint is still shown. Trying to avoid that because the page is black and the hint is always a dark color (black) when the color of the items are white and the spinner is dark (which is good). Just gotta figure out how to get the item to set itself initially to avoid ppl thinking nothing is there 😛

page.getViewById('stateDropDown').on('loaded', ((args: EventData) => {
            console.log(args.object)
            setTimeout(() => {
                this.selectedStateIndex = 0;
            }, 100);
        }))
<dd:DropDown row="0" col="1" id="stateDropDown" color="#fff" hint="State..." items="{{ stateList }}" selectedIndex="{{ selectedStateIndex }}" class="font-18 p-5" />

When tapping the drop down to open the spinner - the 0 based item is selected (and the data in the listview reflects that which is used in a network request) so the issue is just that the hint is still shown and not the 0 index item for my app on iOS.

snip20170421_2

I have to change the spinner list for the value to be in the dropdown and of course not show the hint.

PeterStaev commented 7 years ago

@odubuc , this should now be fixed with version 1.5.4 please try it out.

@bradmartin you can also try the new version, and see if that fixes your problem. I assume in the above example this is an Observable and has correct change notifications set up?

bradmartin commented 7 years ago

Correct @PeterStaev - I'll try the update and let you know.

bradmartin commented 7 years ago

It fixed it, thanks @PeterStaev

odubuc commented 7 years ago

Yes! it works perfectly for me too. Thank you @PeterStaev