diff --git a/src/runtime/components/InputMenu.vue b/src/runtime/components/InputMenu.vue index 528cfecb6c..e8f7413b89 100644 --- a/src/runtime/components/InputMenu.vue +++ b/src/runtime/components/InputMenu.vue @@ -128,15 +128,16 @@ export interface InputMenuProps = ArrayOr } export type InputMenuEmits, VK extends GetItemKeys | undefined, M extends boolean> = Pick & { - change: [payload: Event] - blur: [payload: FocusEvent] - focus: [payload: FocusEvent] - create: [item: string] + 'change': [payload: Event] + 'blur': [payload: FocusEvent] + 'focus': [payload: FocusEvent] + 'create': [item: string] /** Event handler when highlighted element changes. */ - highlight: [payload: { + 'highlight': [payload: { ref: HTMLElement value: GetModelValue } | undefined] + 'remove-tag': [item: GetModelValue] } & GetModelValueEmits type SlotProps = (props: { item: T, index: number }) => any @@ -362,6 +363,7 @@ function onRemoveTag(event: any) { const modelValue = props.modelValue as GetModelValue const filteredValue = modelValue.filter(value => !isEqual(value, event)) emits('update:modelValue', filteredValue as GetModelValue) + emits('remove-tag', event) onUpdate(filteredValue) } } diff --git a/test/components/InputMenu.spec.ts b/test/components/InputMenu.spec.ts index 3e644ac3a1..0fdf637da2 100644 --- a/test/components/InputMenu.spec.ts +++ b/test/components/InputMenu.spec.ts @@ -108,6 +108,13 @@ describe('InputMenu', () => { await input.vm.$emit('update:open', false) expect(wrapper.emitted()).toMatchObject({ blur: [[{ type: 'blur' }]] }) }) + + test('remove-tag event', async () => { + const wrapper = mount(InputMenu, { props: { modelValue: ['Option 1'], items: ['Option 1', 'Option 2'], multiple: true } }) + const input = wrapper.findComponent({ name: 'TagsInputRoot' }) + await input.vm.$emit('remove-tag', 'Option 1') + expect(wrapper.emitted()).toMatchObject({ 'remove-tag': [['Option 1']] }) + }) }) describe('form integration', async () => {