fix(components): [select-v2] scrollbar resets to top after select item (#21257)

* fix(components): [select-v2] scrollbar resets to top after select item

issue #21225

* fix(components): [select-v2] scrollbar resets to top after select item

使用函数包裹能解决isFunction(props.remoteMethod)触发watchEffect的问题

* fix(components): [select-v2] scrollbar resets to top after select item
This commit is contained in:
Spaceman
2025-07-10 17:05:06 +08:00
committed by GitHub
parent e4d3ce2970
commit 94a5d9bb1c

View File

@@ -4,6 +4,7 @@ import {
onMounted,
reactive,
ref,
toRaw,
watch,
watchEffect,
} from 'vue'
@@ -202,10 +203,10 @@ const useSelect = (props: SelectV2Props, emit: SelectV2EmitFn) => {
const filterOptions = (query: string) => {
const regexp = new RegExp(escapeStringRegexp(query), 'i')
const isFilterMethodValid =
props.filterable && isFunction(props.filterMethod)
const { filterMethod, remoteMethod } = toRaw(props)
const isFilterMethodValid = props.filterable && isFunction(filterMethod)
const isRemoteMethodValid =
props.filterable && props.remote && isFunction(props.remoteMethod)
props.filterable && props.remote && isFunction(remoteMethod)
const isValidOption = (o: Option): boolean => {
if (isFilterMethodValid || isRemoteMethodValid) return true
// when query was given, we should test on the label see whether the label contains the given query