PeterStaev / NativeScript-Drop-Down

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

Select 0 (first) Item #225

Closed onkelpete closed 4 years ago

onkelpete commented 4 years ago

Hi, i got bug on iOS with DropDown if it contains only one element. I can not select this element.

"dependencies": {
    "@angular/animations": "8.2.6",
    "@angular/common": "8.2.6",
    "@angular/compiler": "8.2.6",
    "@angular/core": "8.2.6",
    "@angular/forms": "8.2.6",
    "@angular/platform-browser": "8.2.6",
    "@angular/platform-browser-dynamic": "8.2.6",
    "@angular/router": "8.2.6",
    "@nstudio/nativescript-snackbar": "1.0.0",
    "nativescript-angular": "8.2.1",
    "nativescript-camera": "^4.5.0",
    "nativescript-datetimepicker": "1.2.1",
    "nativescript-drop-down": "^5.0.4",
    "nativescript-imagepicker": "^7.1.0",
    "nativescript-ng-shadow": "2.1.0",
    "nativescript-plugin-firebase": "9.1.1",
    "nativescript-theme-core": "1.0.6",
    "reflect-metadata": "0.1.13",
    "rxjs": "6.5.3",
    "tns-core-modules": "6.1.1",
    "zone.js": "0.9.1"
  },

Usage

<StackLayout orientation="vertical">
    <DropDown itemsTextAlignment="center"
              [items]="categories"
              hint="Select Category"
              (selectedIndexChanged)="loadAvailableUnderCategories($event)"></DropDown>

    <DropDown itemsTextAlignment="center"
              hint="Select under category"
              [items]="underCategories"
              (selectedIndexChanged)="loadAvailableLesson($event)"></DropDown>

    <DropDown itemsTextAlignment="center"
              hint="Select lesson"
              [items]="lessons"></DropDown>

</StackLayout>
PeterStaev commented 4 years ago

Hey @MrPitty , this is a known limitation since on iOS the system automatically marks the first element as if it is selected.

I would suggest the following workaround - you subscribe to the the open event of the drop down and if on iOS to automatically select the first value. Another workaround would be to always add a first element that would be the not selected value.

onkelpete commented 4 years ago

H Peter, thanks you for your answer.

Best Regards Peter =)