Select to view content in your preferred language

Calcite Value List: getSelectedItems returns old selection

585
2
12-29-2021 05:53 AM
JoëlHempenius3
Occasional Contributor II
this.itemListViewEl.nativeElement.getSelectedItems().then((elements: any) => {
      const iterator1 = elements.values()
      let selectedElement = iterator1.next().value;
      selectedElement.selected = false;
      elements.clear();
});

 

<calcite-value-list #itemListViewNode (calciteListChange)="checkSelected()">
                <calcite-pick-list-item  *ngFor="let item of qr?.results" [label]="item.title" [value]="item"
                    [description]="item.owner"  selected="false">
                </calcite-pick-list-item>
            </calcite-value-list>

 

I'm working on a Angular, JS API and Calcite Design System application. When call getSelectedItems function from the Calcite Value-List, I get multiple selected items back. I didn't enable multiple. This happens after qr ( PortalQueryResult) is updated with a new PortalQueryResult. In that case I will still get the previously selected item from an previous qr result.

Setting the selected property to false (line 4) doesn't work
Calling clear()  (line 5) on elements does work, but feels weird to call it each time qr object is refreshed with a new result to reset the selected items that way.

Any ideas to get only one selected item from the current PortalQueryResult?

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
0 Kudos
2 Replies
BenElan
Esri Contributor

Hi @JoëlHempenius3, can you put together a GitHub repo or code sandbox that reproduces this issue?

0 Kudos
JoëlHempenius3
Occasional Contributor II

Hi Ben, Thank you for your response. I will try to make a repo with the issue, will post an update here when ready.

-Joël Hempenius.

Languages: JavaScript, Python and Dunglish
0 Kudos