Repository: arco-design/arco-design (TypeScript)

Issue:
select开启allowCreate，遇到远程搜索时，如果远程数据value和当前输入的input value相同，只展示allowCreate生成的option
- [x] I'm sure this does not appear in [the issue list of the repository](https://github.com/arco-design/arco-design/issues)

## 基本信息 
- **依赖包名 及 版本:** @arco-design/web-react@2.44.3
- **浏览器版本:** chrome110.0.0.0
- **复现地址:** https://h8c51o.csb.app/

## 预期结果
展示「fetch 2」

## 复现步骤
先输入2，等待1s后，仅展示了allowCreate生成的2，未展示拉取的数据「fetch 2」

<!--- 声明: 如果提交带有攻击性的 issue，提交者将会被禁止在 arco-design 组织下发言。 -->
<!-- generated by arco-issue. DO NOT REMOVE -->


Discussion:

Patch:
diff --git a/components/Select/utils.tsx b/components/Select/utils.tsx
index e1d7de95c8..36f160024e 100644
--- a/components/Select/utils.tsx
+++ b/components/Select/utils.tsx
@@ -120,7 +120,14 @@ function flatChildren(
       isValidOption = !inputValue || filterOption(inputValue, child);
     }
 
-    if (!optionInfoMap.get(optionValue)) {
+    const existOption = optionInfoMap.get(optionValue);
+    const needOverwriteUserCreatedOption =
+      existOption?._origin === 'userCreatedOptions' ||
+      existOption?._origin === 'userCreatingOption';
+
+    // we don't allow two options with same value
+    // however option created by user-inputting can be replaced by option from option property or children
+    if (!existOption || needOverwriteUserCreatedOption) {
       if (!('_key' in child.props)) {
         child = React.cloneElement(child, {
           _key: getChildKey(child.props, child.key),
@@ -138,13 +145,23 @@ function flatChildren(
       };
 
       optionInfoMap.set(optionValue, option);
-      optionValueList.push(optionValue);
 
-      if (isValidOption) {
-        childrenList.push(child);
+      if (needOverwriteUserCreatedOption) {
+        const indexToUpdate = childrenList.findIndex((c) => c?.props?.value === optionValue);
+        if (indexToUpdate > -1) {
+          isValidOption
+            ? (childrenList[indexToUpdate] = child)
+            : childrenList.splice(indexToUpdate, 1);
+        }
+      } else {
+        optionValueList.push(optionValue);
+
+        if (isValidOption) {
+          childrenList.push(child);
 
-        if (!option.disabled) {
-          optionIndexListForArrowKey.push(index);
+          if (!option.disabled) {
+            optionIndexListForArrowKey.push(index);
+          }
         }
       }
     }


Test patch:
diff --git a/components/Select/__test__/index.test.tsx b/components/Select/__test__/index.test.tsx
index f1281e0615..4f25adffbc 100644
--- a/components/Select/__test__/index.test.tsx
+++ b/components/Select/__test__/index.test.tsx
@@ -6,7 +6,7 @@ import componentConfigTest from '../../../tests/componentConfigTest';
 import Button from '../../Button';
 import Select from '../select';
 import { Enter, Tab } from '../../_util/keycode';
-import { LabeledValue } from '../interface';
+import { LabeledValue, SelectProps } from '../interface';
 
 mountTest(Select);
 componentConfigTest(Select, 'Select');
@@ -425,4 +425,27 @@ describe('Select', () => {
     expect(wrapper.querySelector('.arco-select-view-value').innerHTML).toBe(transformedLabel);
     expect(wrapper.querySelector('.arco-select-option').innerHTML).toBe(transformedLabel);
   });
+
+  it('update option created by user if search result contains same value option', async () => {
+    const Demo = () => {
+      const [options, setOptions] = useState<SelectProps['options']>([]);
+      return (
+        <Select
+          allowCreate
+          popupVisible
+          options={options}
+          filterOption={false}
+          onSearch={(text) => setOptions([{ label: text.toUpperCase(), value: text }])}
+        />
+      );
+    };
+
+    wrapper = render(<Demo />);
+
+    const inputText = 'hello';
+    const eleInput = wrapper.querySelector('input');
+    fireEvent.change(eleInput, { target: { value: inputText } });
+    await sleep(100);
+    expect(wrapper.querySelector('.arco-select-option')).toHaveTextContent(inputText.toUpperCase());
+  });
 });