fix(select): [select] fix event retargeting in debounce (#1154)

This commit is contained in:
gimmyhehe 2023-12-19 15:20:21 +08:00 committed by GitHub
parent 0b79fdd044
commit 0dc0dd25a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 4 deletions

View File

@ -191,6 +191,18 @@ export const handleQueryChange =
api.defaultOnQueryChange(value)
}
export const debouncedQueryChange =
({ props, api }) =>
(event) => {
const value = props.shape ? event : event.target.value
api.handleDebouncedQueryChange(value)
}
export const handleDebouncedQueryChange = ({ state, api }) =>
debounce(state.debounce, (value) => {
api.handleQueryChange(value)
})
export const scrollToOption =
({ vm, constants }) =>
(option) => {

View File

@ -107,7 +107,9 @@ import {
computedGetIcon,
computedGetTagType,
computedShowDropdownIcon,
clearNoMatchValue
clearNoMatchValue,
debouncedQueryChange,
handleDebouncedQueryChange
} from './index'
import debounce from '../common/deps/debounce'
import { isNumber } from '../common/type'
@ -289,9 +291,8 @@ const addApi = ({ api, props, state, emit, constants, parent, nextTick, dispatch
handleOptionSelect: handleOptionSelect({ api, nextTick, props, vm, state }),
getPluginOption: getPluginOption({ api, props, state }),
toggleCheckAll: toggleCheckAll({ api, emit, state, props }),
debouncedQueryChange: debounce(state.debounce, (event) => {
api.handleQueryChange(props.shape ? event : event.target.value)
}),
handleDebouncedQueryChange: handleDebouncedQueryChange({ state, api }),
debouncedQueryChange: debouncedQueryChange({ props, api }),
debouncedOnInputChange: debounce(state.debounce, () => {
api.onInputChange()
}),