Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(select): 新增带搜索情况下,点击叉号按钮时下拉框同时清空(#2945) #2948

Merged
merged 6 commits into from
Aug 1, 2024

Conversation

xiamiao1121
Copy link
Contributor

搜索非受控模式下支持
closed #2945

@@ -236,7 +236,7 @@ export const Select = forwardRef<HTMLDivElement | null, SelectProps>(
onOpen={menuVisibleAction.on}
onClose={menuVisibleAction.off}
searchable={searchable}
keyword={keywordProp}
keyword={searchValue}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

此处这样改会影响搜索关键字的受控

/**
* 提供辅助方法的内部引用
*/
innerRef?: React.Ref<HTMLDivElement>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTMLDivElement 改为 useImperativeHandle 中声明的方法,例如:interface PikcerHelper {resetSearch: () => void}

customRender,
...rest
},
ref
) => {
const i18n = useLocaleContext()

const innerRef = useRef<HTMLDivElement>()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HTMLDivElement 改为上面说的 PikcerHelper

@@ -227,7 +229,7 @@ export const Select = forwardRef<HTMLDivElement | null, SelectProps>(
return (
<SelectProvider value={context}>
<Picker
ref={ref}
ref={mergeRefs(ref, innerRef)}
Copy link
Collaborator

@zyprepare zyprepare Jul 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议将 innerRef 放在该行下面,另外有了 innerRef 后不需要在使用 mergeRefs

@zyprepare zyprepare added enhancement New feature or request comp:select 4.x PR: New feature 👍 New feature pull request and removed enhancement New feature or request labels Aug 1, 2024
@zyprepare zyprepare merged commit 4d82491 into XiaoMi:master Aug 1, 2024
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select 期望带搜索情况下,点击叉号按钮时下拉框同时清空
2 participants