Skip to content

Commit

Permalink
🔧 fix sorted items on multi-select
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-gn committed Oct 9, 2023
1 parent 5568405 commit c9087c5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

| Angular Version | NPM Package Version |
|-----------------|---------------------|
| ^16.1.4 | 16.1.9 |
| ^16.1.4 | 16.1.10 |
| 15.0.4 | 15.0.6 |
| 13.2.3 | 13.0.22 |
| < 13.0.0 | 0.0.77 |
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mprisma/components",
"version": "16.1.9",
"version": "16.1.10",
"repository": {
"type": "git",
"url": "https://github.com/gabriel-gn/prisma-components.git"
Expand Down
7 changes: 5 additions & 2 deletions src/components/inputs/multi-select/multi-select.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,15 @@ export class MultiSelectComponent implements OnInit, AfterViewInit, ControlValue
}

public selectOption(option: any): void {
this.selectedOptions.push(option);
const currentOptions = this.selectedOptions;
currentOptions.push(option);

if (this.sortSelectedItems) {
this.selectedOptions = this.selectedOptions.sort((a, b) => {
this.selectedOptions = currentOptions.sort((a, b) => {
return this.options.indexOf(a) - this.options.indexOf(b);
});
} else {
this.selectedOptions = currentOptions;
}
this.blurInputSelect();
}
Expand Down

1 comment on commit c9087c5

@vercel
Copy link

@vercel vercel bot commented on c9087c5 Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.