Skip to content

Commit

Permalink
fix(admin-ui): Fix error when saving multiple new variant options
Browse files Browse the repository at this point in the history
Fixes #2326
  • Loading branch information
michaelbromley committed Aug 11, 2023
1 parent ada153e commit e5ad0ee
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
SelectionManager,
} from '@vendure/admin-ui/core';
import { normalizeString } from '@vendure/common/lib/normalize-string';
import { unique } from '@vendure/common/lib/unique';
import { EMPTY, Observable, Subject } from 'rxjs';
import { map, startWith, switchMap } from 'rxjs/operators';

Expand Down Expand Up @@ -296,14 +297,15 @@ export class ProductVariantsEditorComponent implements OnInit, DeactivateAware {
}

addOptionToVariant(variant: NonNullable<GetProductVariantOptionsQuery['product']>['variants'][number]) {
const optionIds = [
...variant.options.map(o => o.id),
...Object.values(this.optionsToAddToVariant[variant.id]),
];
this.dataService.product
.updateProductVariants([
{
id: variant.id,
optionIds: [
...variant.options.map(o => o.id),
...Object.values(this.optionsToAddToVariant[variant.id]),
],
optionIds: unique(optionIds),
},
])
.subscribe(({ updateProductVariants }) => {
Expand Down

0 comments on commit e5ad0ee

Please sign in to comment.