Skip to content

Commit

Permalink
fix(VAutocomplete/VCombobox): consistent open/close transition
Browse files Browse the repository at this point in the history
  • Loading branch information
J-Sek committed Dec 8, 2024
1 parent ca85fc0 commit 15ffb05
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import { forwardRefs } from '@/composables/forwardRefs'
import { useItems } from '@/composables/list-items'
import { useLocale } from '@/composables/locale'
import { useProxiedModel } from '@/composables/proxiedModel'
import { makeTransitionProps } from '@/composables/transition'

// Utilities
import { computed, mergeProps, nextTick, ref, shallowRef, watch } from 'vue'
Expand Down Expand Up @@ -87,7 +86,6 @@ export const makeVAutocompleteProps = propsFactory({
modelValue: null,
role: 'combobox',
}), ['validationValue', 'dirty', 'appendInnerIcon']),
...makeTransitionProps({ transition: false }),
}, 'VAutocomplete')

type ItemType<T> = T extends readonly (infer U)[] ? U : never
Expand Down Expand Up @@ -368,7 +366,6 @@ export const VAutocomplete = genericComponent<new <
// watch for search watcher to trigger
nextTick(() => {
menu.value = false
isPristine.value = true
})
}
}
Expand Down Expand Up @@ -470,7 +467,6 @@ export const VAutocomplete = genericComponent<new <
maxHeight={ 310 }
openOnClick={ false }
closeOnContentClick={ false }
transition={ props.transition }
onAfterEnter={ onAfterEnter }
onAfterLeave={ onAfterLeave }
{ ...props.menuProps }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { VForm } from '@/components/VForm'
// Utilities
import { generate, render, screen, userEvent, waitAnimationFrame, waitIdle } from '@test'
import { findAllByRole, queryAllByRole, within } from '@testing-library/vue'
import { commands } from '@vitest/browser/context'
import { cloneVNode, ref } from 'vue'

const variants = ['underlined', 'outlined', 'filled', 'solo', 'plain'] as const
Expand Down Expand Up @@ -82,6 +83,7 @@ describe('VAutocomplete', () => {
))

await userEvent.click(container)
await commands.waitStable('.v-list')

const menu = await screen.findByRole('listbox')

Expand Down Expand Up @@ -128,6 +130,7 @@ describe('VAutocomplete', () => {
))

await userEvent.click(container)
await commands.waitStable('.v-list')

const menu = await screen.findByRole('listbox')

Expand Down Expand Up @@ -179,6 +182,7 @@ describe('VAutocomplete', () => {
))

await userEvent.click(container)
await commands.waitStable('.v-list')

const menu = await screen.findByRole('listbox')

Expand Down Expand Up @@ -304,6 +308,7 @@ describe('VAutocomplete', () => {
))

await userEvent.click(element)
await commands.waitStable('.v-list')

await userEvent.click(screen.getAllByRole('option')[0])
expect(selectedItems.value).toBe(1)
Expand Down
6 changes: 0 additions & 6 deletions packages/vuetify/src/components/VCombobox/VCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { forwardRefs } from '@/composables/forwardRefs'
import { transformItem, useItems } from '@/composables/list-items'
import { useLocale } from '@/composables/locale'
import { useProxiedModel } from '@/composables/proxiedModel'
import { makeTransitionProps } from '@/composables/transition'

// Utilities
import { computed, mergeProps, nextTick, ref, shallowRef, watch } from 'vue'
Expand Down Expand Up @@ -91,7 +90,6 @@ export const makeVComboboxProps = propsFactory({
modelValue: null,
role: 'combobox',
}), ['validationValue', 'dirty', 'appendInnerIcon']),
...makeTransitionProps({ transition: false }),
}, 'VCombobox')

type ItemType<T> = T extends readonly (infer U)[] ? U : never
Expand Down Expand Up @@ -304,8 +302,6 @@ export const VCombobox = genericComponent<new <
) {
select(filteredItems.value[0])
}

isPristine.value = true
}

if (e.key === 'ArrowDown' && highlightFirst.value) {
Expand Down Expand Up @@ -403,7 +399,6 @@ export const VCombobox = genericComponent<new <
// watch for search watcher to trigger
nextTick(() => {
menu.value = false
isPristine.value = true
})
}
}
Expand Down Expand Up @@ -514,7 +509,6 @@ export const VCombobox = genericComponent<new <
maxHeight={ 310 }
openOnClick={ false }
closeOnContentClick={ false }
transition={ props.transition }
onAfterEnter={ onAfterEnter }
onAfterLeave={ onAfterLeave }
{ ...props.menuProps }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { VForm } from '@/components/VForm'

// Utilities
import { generate, render, screen, userEvent, waitAnimationFrame, waitIdle } from '@test'
import { commands } from '@vitest/browser/context'
import { cloneVNode, ref } from 'vue'

const variants = ['underlined', 'outlined', 'filled', 'solo', 'plain'] as const
Expand Down Expand Up @@ -92,6 +93,7 @@ describe('VCombobox', () => {
))

await userEvent.click(element)
await commands.waitStable('.v-list')
await userEvent.click((await screen.findAllByRole('option'))[0])
expect(model.value).toStrictEqual(items[0])
expect(search.value).toBe(items[0].title)
Expand Down Expand Up @@ -139,6 +141,7 @@ describe('VCombobox', () => {
))

await userEvent.click(element)
await commands.waitStable('.v-list')
await userEvent.click(screen.getAllByRole('option')[0])
expect(model.value).toStrictEqual([items[0]])
expect(search.value).toBeUndefined()
Expand Down Expand Up @@ -360,6 +363,7 @@ describe('VCombobox', () => {
))

await userEvent.click(element)
await commands.waitStable('.v-list')

const options = await screen.findAllByRole('option', { selected: true })
expect(options).toHaveLength(2)
Expand Down Expand Up @@ -467,6 +471,7 @@ describe('VCombobox', () => {
))

await userEvent.click(element)
await commands.waitStable('.v-list')

await userEvent.click(screen.getAllByRole('option')[0])

Expand Down Expand Up @@ -728,6 +733,7 @@ describe('VCombobox', () => {
))

await userEvent.click(element)
await commands.waitStable('.v-list')
await userEvent.click(screen.getAllByRole('option')[0])
expect(model.value).toStrictEqual({ title: 'Item 1', value: 'item1' })

Expand Down

0 comments on commit 15ffb05

Please sign in to comment.