Browse Source

fix(@vben/common-ui): sync selected icon with configured model

pull/8339/head
atian 4 weeks ago
parent
commit
616b7999d6
  1. 23
      packages/effects/common-ui/src/components/icon-picker/__tests__/icon-picker.test.ts
  2. 3
      packages/effects/common-ui/src/components/icon-picker/icon-picker.vue

23
packages/effects/common-ui/src/components/icon-picker/__tests__/icon-picker.test.ts

@ -173,4 +173,27 @@ describe('icon-picker.vue', () => {
wrapper.unmount();
});
it('updates the configured model value when selecting an icon', async () => {
const onUpdateValue = vi.fn();
const wrapper = mount(IconPicker, {
attachTo: document.body,
props: {
icons: STATIC_ICONS,
inputComponent: markRaw(AntdvNextLikeInput),
modelValueProp: 'value',
prefix: '',
'onUpdate:value': onUpdateValue,
},
});
await openIconPicker(wrapper);
const firstIcon = document.body.querySelector('.grid-cols-6 > button');
expect(firstIcon).toBeTruthy();
await new DOMWrapper(firstIcon as Element).trigger('click');
expect(onUpdateValue).toHaveBeenCalledWith('home');
wrapper.unmount();
});
});

3
packages/effects/common-ui/src/components/icon-picker/icon-picker.vue

@ -111,8 +111,7 @@ watch(
);
const handleClick = (icon: string) => {
currentSelect.value = icon;
modelValue.value = icon;
updateCurrentSelect(icon);
close();
};

Loading…
Cancel
Save