nativescript-accordion icon indicating copy to clipboard operation
nativescript-accordion copied to clipboard

itemContentTap returns wrong childIndex / data

Open manojdcoder opened this issue 6 years ago • 2 comments
trafficstars

itemContentTap returns wrong childIndex / data, clicking on 0th index returns 1 at childIndex and data from 1st index. If I click on last content item, data will be undefined.

Which platform(s) does your issue occur on?

  • iOS
  • iOS 12.1
  • iPhone XR / iPad 6th Gen

Please, provide the following version numbers that your issue occurs with:

  • CLI: 5.0.3
  • Cross-platform modules: 5.1.0
  • Runtime(s): 5.1.0
  • Plugin(s): 6.0.0-beta.2

Please, tell us how to recreate the issue in as much detail as possible.

Describe the steps to reproduce it.

Is there any code involved?

HTML

 <Accordion class="list-group" [items]="groups"
            (itemContentTap)="onItemContentTap($event)">
            <ng-template let-group="item" acTemplateKey="title">
                <GridLayout class="p-10 bg-muted header-separator">
                    <Label class="font-weight-bold" [text]="group.title"></Label>
                </GridLayout>
            </ng-template>
            <ng-template let-item="item" acTemplateKey="content">
                <Label class="list-group-item" [text]="item.display"></Label>
            </ng-template>
        </Accordion>

TS

 groups: { title: string, items: { display: string }[] }[] = [
    {
        title: "Group 1",
        items: [
              { display: "Item 1" },
              { display: "Item 2" },
              { display: "Item 3" },
        ]
    },
   {
        title: "Group 2",
        items: [
              { display: "Item 1" },
              { display: "Item 2" },
              { display: "Item 3" },
        ]
    }
];

  onItemContentTap(event) {
        const data = event.data;
        console.log(event.index);
        console.log(event.childIndex); // Index is always one more than what user taps
        console.log(data);  
    }

manojdcoder avatar Dec 14 '18 20:12 manojdcoder

Same here. Indexing starts from 1 instead of 0 on iOS only.

asologor avatar Jun 21 '19 15:06 asologor

Any workaround here?

hakkism avatar Aug 06 '19 07:08 hakkism