Rich text, multiselect, useFormset fixes (#1077)
* Rich text field fix * Fix useFormset setItemValue * Update changelog
This commit is contained in:
parent
6395aa16a3
commit
d48c0087e0
5 changed files with 19 additions and 12 deletions
|
@ -36,6 +36,10 @@ All notable, unreleased changes to this project will be documented in this file.
|
|||
- Add shipping method description - #1058 by @jwm0
|
||||
- Fix voucher and sales sorting errors - #1063 by @orzechdev
|
||||
- Fix custom currency formatting - #1067 by @orzechdev
|
||||
- Fixes - #1077 by @piotrgrundas:
|
||||
- rich text field updates,
|
||||
- multiselect empty chip upon creation of a product/variant,
|
||||
- useFormset.setItemValue wrong updates,
|
||||
|
||||
# 2.11.1
|
||||
|
||||
|
|
|
@ -80,6 +80,9 @@ export function getSelectedAttributeValues(
|
|||
if (attribute.attribute.inputType === AttributeInputTypeEnum.REFERENCE) {
|
||||
return attribute.values.map(value => value.reference);
|
||||
}
|
||||
if (attribute.attribute.inputType === AttributeInputTypeEnum.RICH_TEXT) {
|
||||
return [attribute.values[0]?.richText];
|
||||
}
|
||||
return attribute.values.map(value => value.slug);
|
||||
}
|
||||
|
||||
|
|
|
@ -46,15 +46,17 @@ function useFormset<TData = {}, TValue = any>(
|
|||
}
|
||||
|
||||
function setItemValue(id: string, value: TValue) {
|
||||
const itemIndex = data.findIndex(item => item.id === id);
|
||||
setData([
|
||||
...data.slice(0, itemIndex),
|
||||
{
|
||||
...data[itemIndex],
|
||||
value
|
||||
},
|
||||
...data.slice(itemIndex + 1)
|
||||
]);
|
||||
setData(data => {
|
||||
const itemIndex = data.findIndex(item => item.id === id);
|
||||
return [
|
||||
...data.slice(0, itemIndex),
|
||||
{
|
||||
...data[itemIndex],
|
||||
value
|
||||
},
|
||||
...data.slice(itemIndex + 1)
|
||||
];
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -135,8 +135,6 @@ function useProductVariantUpdateForm(
|
|||
makeChangeHandler: makeMetadataChangeHandler
|
||||
} = useMetadataChangeTrigger();
|
||||
|
||||
// console.log({ attributes, initial });
|
||||
|
||||
const handleChange: FormChange = (event, cb) => {
|
||||
form.change(event, cb);
|
||||
triggerChange();
|
||||
|
|
|
@ -92,7 +92,7 @@ export function getAttributeInputFromAttributes(
|
|||
},
|
||||
id: attribute.id,
|
||||
label: attribute.name,
|
||||
value: [""]
|
||||
value: []
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue