Skip to content
Snippets Groups Projects

fix: list aspect multi selection

Merged Daniel Schmidt requested to merge instantnoodl/fix-list-aspect into master
1 file
+ 9
6
Compare changes
  • Side-by-side
  • Inline
@@ -16,7 +16,7 @@ export class ListAspect extends StringAspect {
}
export const ListAspectSchema = (
values: Array<string> | Record<string, string>,
values: string[] | Record<string, string>,
placeholder?: string,
translateValues?: ({ value, translation }) => string,
advancedModes?: boolean,
@@ -31,8 +31,12 @@ export const ListAspectSchema = (
// * Ensure value is valid
const keys = !Array.isArray(values) ? Object.values(values) : values;
if (aspectValue.value && !keys.includes(aspectValue.value)) {
aspectValue.value = null;
if (aspectValue.value) {
const trimmedValues = aspectValue.value.split(',').map(v => v.trim());
const fixed = trimmedValues.filter(v => keys.includes(v)).join(',');
if (aspectValue.value !== fixed) {
aspectValue.value = fixed;
}
}
return html`
@@ -58,10 +62,9 @@ export const ListAspectSchema = (
placeholder-mode="hide"
.renderString=${(s: string) => (translateValues ? translateValues({ value: s, translation }) : s)}
.search=${(search: Maybe<string>) => {
let arrayValues: string[] = keys.map(v => v.toString());
const arrayValues: string[] = keys.map(v => v.toString());
const mappedValues = arrayValues.map(value => ({
value: value,
value,
trans: translateValues ? translateValues({ value, translation }) : value,
}));
Loading