React admin AutocompleteInput在第一次单击时没有价值

问题描述 投票:0回答:1

我已经添加了AutocompleteInput来选择作者。当我在AutocompleteInput中搜索作者的姓名并单击要显示的姓名时,它不会显示所选的值。当我第二次这样做时,它会显示先前选择的值。

这是我的代码,

     <AutocompleteInput source="AuthorUid" label="Author" choices={this.state.authorList}))}/>
reactjs react-admin
1个回答
0
投票
我的自定义组件->

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>
© www.soinside.com 2019 - 2024. All rights reserved.