Skip to content

feature(select): trackByFn #6970

@julianobrasil

Description

@julianobrasil

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

If you change the datasource used to generate the options, the selected value should be kept. It already works like this for primitive options' values. For complex options' values, something like *ngFor's trackByFunction could take care of which attribute would define whether one of the new options is equals to the one already selected.

What is the current behavior?

When the options' values are not primitive types and you change the options' datasource, the selected value is unset even if it's present in the new datasource.

What are the steps to reproduce?

Plunk: https://plnkr.co/edit/GJn833kKV1qaMthxDmMe?p=preview

In the plunk, select an option and then click on the reload datasource button. The selected value will not be kept.

What is the use-case or motivation for changing an existing behavior?

It would simplify the developer's code if something like trackBy="'id'" or trackBy="'owner.personalDocuments.socialSecurityNumber'" was possible to do.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions