Skip to content

Commit

Permalink
fix(admin-ui): Fix product multi select form input
Browse files Browse the repository at this point in the history
Relates to #2249
  • Loading branch information
michaelbromley committed Jun 29, 2023
1 parent 7498901 commit b5947ec
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CustomFieldConfig } from '../../common/generated-types';
* as expected by the server.
*/
export function transformRelationCustomFieldInputs<
T extends { input?: Record<string, any> | Array<Record<string, any>> } & Record<string, any> = any
T extends { input?: Record<string, any> | Array<Record<string, any>> } & Record<string, any> = any,
>(variables: T, customFieldConfig: CustomFieldConfig[]): T {
if (variables.input) {
if (Array.isArray(variables.input)) {
Expand Down Expand Up @@ -36,7 +36,7 @@ function transformRelations<T>(input: T, customFieldConfig: CustomFieldConfig[])
delete input.customFields[field.name];
input.customFields[getGraphQlInputName(field)] =
field.list && Array.isArray(entityValue)
? entityValue.map(v => v?.id)
? entityValue.map(v => (typeof v === 'string' ? v : v?.id))
: entityValue === null
? null
: entityValue?.id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export class ProductMultiSelectorFormInputComponent implements OnInit, FormInput
size: 'xl',
locals: {
mode: this.mode,
initialSelectionIds: this.formControl.value,
initialSelectionIds: this.formControl.value.map(item =>
typeof item === 'string' ? item : item.id,
),
},
})
.subscribe(selection => {
Expand All @@ -47,6 +49,7 @@ export class ProductMultiSelectorFormInputComponent implements OnInit, FormInput
this.mode === 'product' ? item.productId : item.productVariantId,
),
);
this.formControl.markAsDirty();
this.changeDetector.markForCheck();
}
});
Expand Down

0 comments on commit b5947ec

Please sign in to comment.