From c1ff745095d594eae16424b7b530213741288621 Mon Sep 17 00:00:00 2001 From: yinkaihui Date: Fri, 26 Apr 2024 15:55:17 +0800 Subject: [PATCH 1/2] enhance: select focus creating option --- components/Select/select.tsx | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/components/Select/select.tsx b/components/Select/select.tsx index 564be0633f..85778b2c6f 100644 --- a/components/Select/select.tsx +++ b/components/Select/select.tsx @@ -45,6 +45,9 @@ import useMergeProps from '../_util/hooks/useMergeProps'; import { SelectOptionProps } from '../index'; import useId from '../_util/hooks/useId'; +// 用户创建中的option的origin标识 +const USER_CREATING_OPTION_ORIGIN = 'userCreatingOption'; + const defaultProps: SelectProps = { trigger: 'click', bordered: true, @@ -185,7 +188,12 @@ function Select(baseProps: SelectProps, ref) { // if it's not rendered (e.g. filtered by user-search), ignore it const isFirstValueOptionSelectable = !isNoOptionSelected && optionInfoMap.get(firstValue)?._valid; - return isFirstValueOptionSelectable + + // 是否第一个 option 是创建中选项 + const isFirstCreatingOption = + optionInfoMap?.get(optionValueList[0])?._origin === USER_CREATING_OPTION_ORIGIN; + + return isFirstValueOptionSelectable && !isFirstCreatingOption ? firstValue : optionValueList[optionIndexListForArrowKey[0]]; } @@ -305,7 +313,7 @@ function Select(baseProps: SelectProps, ref) { .filter((v) => { const option = optionInfoMap.get(v) || refValueMap.current.find((item) => item.value === v)?.option; - return !option || option._origin === 'userCreatingOption'; + return !option || option._origin === USER_CREATING_OPTION_ORIGIN; }) .map((op) => userCreatedOptionFormatter(op as string)); // 将 value 中不存在的 Option 移除 From ebae6a5105955cc80f845dcd538e7c7a708bf8dd Mon Sep 17 00:00:00 2001 From: yinkaihui Date: Fri, 26 Apr 2024 15:56:15 +0800 Subject: [PATCH 2/2] ci: update node version --- .github/workflows/deploy-site-preview.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-site-preview.yml b/.github/workflows/deploy-site-preview.yml index 5e7a668451..850a1fd3ed 100644 --- a/.github/workflows/deploy-site-preview.yml +++ b/.github/workflows/deploy-site-preview.yml @@ -48,7 +48,7 @@ jobs: - name: setup node uses: actions/setup-node@v3 with: - node-version: 16 + node-version: 18 cache: 'yarn' - name: Download site-dist Artifact