Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/runtime/components/InputMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,16 @@ function onUpdate(value: any) {
}

function onInputUpdate(value: string) {
if (!isAutocomplete.value) {
searchTerm.value = value
if (isAutocomplete.value) {
return
}

// While closed, reka resets the input to the label of the selected item, which isn't a search.
if (!isOpen.value && value && value === displayValue(props.modelValue as GetItemValue<T, VK, ExcludeItem>)) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
return
}

searchTerm.value = value
}

function onBlur(event: FocusEvent) {
Expand Down
10 changes: 10 additions & 0 deletions test/components/InputMenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,16 @@ describe('InputMenu', () => {
expect(emissions).toBeTruthy()
expect(emissions![emissions!.length - 1]).toEqual(['Option 2'])
})

test('searchTerm ignores the label when parent updates modelValue', async () => {
const wrapper = mount(InputMenu, { props: { items: ['Option 1', 'Option 2'], modelValue: 'Option 1' } })
await flushPromises()

await wrapper.setProps({ modelValue: 'Option 2' })
await flushPromises()

expect(wrapper.emitted('update:searchTerm')?.flat() ?? []).not.toContain('Option 2')
})
})

describe('clear', () => {
Expand Down
Loading