fix(components): [select-v2] empty value check error in inputRef (#19140)

* fix(components): [select-v2] empty value check error in inputRef

* test(components): [select-v2] empty value check error in inputRef

* fix: test case
This commit is contained in:
Liao-js 2024-12-09 17:04:29 +08:00 committed by GitHub
parent 866f45aaac
commit e17ec9a8a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 26 additions and 1 deletions

View File

@ -1371,6 +1371,31 @@ describe('Select', () => {
expect(placeholder.text()).toBe('option_a')
})
it('the scroll position of the dropdown should be correct when value is 0', async () => {
const options = Array.from({ length: 1000 }).map((_, idx) => ({
value: 999 - idx,
label: `options ${999 - idx}`,
}))
const wrapper = createSelect({
data() {
return {
value: 0,
options,
}
},
})
await nextTick()
await wrapper.find(`.${WRAPPER_CLASS_NAME}`).trigger('click')
const optionsDoms = Array.from(
document.querySelectorAll(`.${OPTION_ITEM_CLASS_NAME}`)
)
const result = optionsDoms.some((option) => {
const text = option.textContent
return text === 'options 0'
})
expect(result).toBeTruthy()
})
it('emptyText error show', async () => {
const wrapper = createSelect({
data() {

View File

@ -330,7 +330,7 @@ const useSelect = (props: ISelectV2Props, emit: SelectEmitFn) => {
}
} else {
if (
props.modelValue &&
!isEmptyValue(props.modelValue) &&
filteredOptionsValueMap.value.has(props.modelValue)
) {
const { index } = filteredOptionsValueMap.value.get(props.modelValue)