我已经添加了AutocompleteInput来选择作者。当我在AutocompleteInput中搜索作者的姓名并单击要显示的姓名时,它不会显示所选的值。当我第二次这样做时,它会显示先前选择的值。
这是我的代码,
<AutocompleteInput source="AuthorUid" label="Author" choices={this.state.authorList}))}/>
renderSelectField = ({ input, label, meta: { touched, error }, children, ...custom }) => {
const dropdownMenuProps = {
menuStyle: {
top: "360px",
height: "347px",
left: "79px",
},
}
return(
<MuiThemeProvider>
<SelectField
floatingLabelText={label}
errorText={touched && error}
{...input}
dropDownMenuProps={dropdownMenuProps}
onChange={(event, index, value) => input.onChange(value)}
children={children}
{...custom}/>
</MuiThemeProvider>
);
}
我使用了自定义组件,例如->
<Field name="AuthorUid" component={this.renderSelectField} label="Author">
{ authors.map((author) =>
<MenuItem value={author.id} primaryText={author.name} />
})}
</Field>