From 94a5d9bb1cb2fc4f2eb892749a9fd360698f1ea3 Mon Sep 17 00:00:00 2001 From: Spaceman Date: Thu, 10 Jul 2025 17:05:06 +0800 Subject: [PATCH] fix(components): [select-v2] scrollbar resets to top after select item (#21257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- packages/components/select-v2/src/useSelect.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/components/select-v2/src/useSelect.ts b/packages/components/select-v2/src/useSelect.ts index a6e3194616..f49790629d 100644 --- a/packages/components/select-v2/src/useSelect.ts +++ b/packages/components/select-v2/src/useSelect.ts @@ -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