diff --git a/package.json b/package.json index b2dc16eff..d84e58143 100644 --- a/package.json +++ b/package.json @@ -34,7 +34,7 @@ "build": "dumi build", "prepare": "husky && dumi setup", "compile": "father build && lessc assets/index.less assets/index.css", - "prepublishOnly": "npm run compile && np --yolo --no-publish --branch 14.x", + "prepublishOnly": "npm run compile && np --yolo --no-publish --branch antd-5.x", "prettier": "prettier --write --ignore-unknown .", "lint": "eslint src/ docs/ tests/ --ext .tsx,.ts,.jsx,.js", "test": "rc-test", diff --git a/src/OptionList.tsx b/src/OptionList.tsx index d4c0109fb..a4859b248 100644 --- a/src/OptionList.tsx +++ b/src/OptionList.tsx @@ -154,7 +154,10 @@ const OptionList: React.ForwardRefRenderFunction = (_, r const timeoutId = setTimeout(() => { if (!multiple && open && rawValues.size === 1) { const value: RawValueType = Array.from(rawValues)[0]; - const index = memoFlattenOptions.findIndex(({ data }) => data.value === value); + // Scroll to the option closest to the searchValue if searching. + const index = memoFlattenOptions.findIndex(({ data }) => + searchValue ? String(data.value).startsWith(searchValue) : data.value === value, + ); if (index !== -1) { setActive(index);