Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ordering of selected items unexpectedly changes when using a custom filter #907

Closed
shusson opened this issue Oct 30, 2018 · 0 comments · Fixed by #923
Closed

ordering of selected items unexpectedly changes when using a custom filter #907

shusson opened this issue Oct 30, 2018 · 0 comments · Fixed by #923
Labels

Comments

@shusson
Copy link

shusson commented Oct 30, 2018

We are finding that the order of the selected items (only in the UI not the ngModel) is being affected by the results from a custom filter.

Example template

<ng-select
    [items]="search$ | async"
    [typeahead]="autocompleteInput$"
    [multiple]="true"
    [clearSearchOnAdd]="true"
    [closeOnSelect]="false"
    [(ngModel)]="filter.values">

    <ng-template ng-option-tmp let-item="item" let-searchTerm="searchTerm">
        <span>{{ item }}</span>
    </ng-template>

</ng-select>

Reproducbile example
https://github.com/shusson/test-ng-select

To Reproduce

  1. setup up and run angular app from https://github.com/shusson/test-ng-select
  2. click on ng-select component
  3. add all terms
  4. search for d
  5. add all terms
  6. search for d
  7. clear search term (delete d)

Expected behaviour
The order of the selected items doesn't change.

Actual behaviour
The order of the selected changes. It seems to be based on what is in the results of the filter. The bound filter.values doesn't change ordering.

Screenshots
image

image

Desktop (please complete the following information):

  • macOS 10.14
  • Chrome 69.0.3497.100
AndersTornkvist added a commit to AndersTornkvist/ng-select that referenced this issue Dec 31, 2018
* remotes/main/master: (25 commits)
  chore(release): 2.13.3
  fix: keep selected items while bindValue is incorrect closes ng-select#993
  chore(release): 2.13.2
  fix: appended dropdown position (ng-select#957)
  chore(release): 2.13.1
  fix: map selected items while source changed closes ng-select#980, ng-select#977, ng-select#959
  chore(release): 2.13.0
  [fix] - $event.path does not work in Safari and Firefox. Replace with $event.composedPath(). (ng-select#968)
  feat(templates): add searchTerm to header and footer (ng-select#961)
  chore(release): 2.12.1
  chore: include scss with package closes ng-select#909
  fix: use classList instead of className closes ng-select#940
  add aria-selected attribute on selected items (ng-select#936)
  fix: handler mousedown for clear event when used animation library (ng-select#931)
  chore(release): 2.12.0
  feat(autofocus): focus if attribute is present (ng-select#924)
  feat(isOpen): treat undefined value as default behaviour closes ng-select#816
  feat: allow to customise clear icon fixes ng-select#835
  chore(demo): fix virtual scroll example closes ng-select#921
  fix: keep items order while mapping selected options fixes ng-select#907
  ...
NickMele pushed a commit to NickMele/ng-select that referenced this issue Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants