fix(forms): 修复 Select 组件 showSearch 属性传递和样式问题

- 将 FormItemsRenderer 中 Select 组件的 showSearch 属性改为对象格式以支持 optionFilterProp
- 修改 Basic Select 组件中 showSearch 属性为对象格式以支持 optionFilterProp
- 修复 FormItemsRenderer 中表单项容器样式,添加 minWidth 以避免布局问题
2.0
LiuJiaNan 2026-06-23 14:06:40 +08:00
parent e9962bf995
commit b4adc46214
2 changed files with 3 additions and 3 deletions

View File

@ -302,7 +302,7 @@ const FormItemsRenderer = ({
case FORM_ITEM_RENDER_ENUM.SELECT: case FORM_ITEM_RENDER_ENUM.SELECT:
return ( return (
<Select placeholder={placeholder} showSearch allowClear optionFilterProp="children" {...componentProps}> <Select placeholder={placeholder} showSearch={{ optionFilterProp: "children" }} allowClear {...componentProps}>
{(option.items || []).map((item) => { {(option.items || []).map((item) => {
const { value, label, disabled } = getSelectableItemAttributes(item, itemsFieldKey); const { value, label, disabled } = getSelectableItemAttributes(item, itemsFieldKey);
return ( return (
@ -619,7 +619,7 @@ const FormItemsRenderer = ({
{...formItemProps} {...formItemProps}
> >
<div style={{ display: "flex", gap: 10, alignItems: "center", justifyContent: "space-between" }}> <div style={{ display: "flex", gap: 10, alignItems: "center", justifyContent: "space-between" }}>
<div style={{ flex: 1 }}> <div style={{ flex: 1, minWidth: 0 }}>
<Form.Item <Form.Item
noStyle noStyle
rules={getRules(listOption)} rules={getRules(listOption)}

View File

@ -59,7 +59,7 @@ function BasicSelect(props) {
}, [data]); }, [data]);
return ( return (
<Select placeholder={`请选择${placeholder}`} showSearch allowClear optionFilterProp="children" onChange={handleChange} {...restProps}> <Select placeholder={`请选择${placeholder}`} showSearch={{ optionFilterProp: "children" }} allowClear onChange={handleChange} {...restProps}>
{data.map((item) => { {data.map((item) => {
const value = item[idKey]; const value = item[idKey];
const label = labelRender ? labelRender(item) : item[nameKey]; const label = labelRender ? labelRender(item) : item[nameKey];