fix(widget-relation): fix displayFields default (#3783)
This commit is contained in:
parent
2f435f875b
commit
24d96a760a
@ -155,7 +155,7 @@ export default class RelationControl extends React.Component {
|
||||
parseHitOptions = hits => {
|
||||
const { field } = this.props;
|
||||
const valueField = field.get('valueField');
|
||||
const displayField = field.get('displayFields') || List(field.get('valueField'));
|
||||
const displayField = field.get('displayFields') || List([field.get('valueField')]);
|
||||
|
||||
const options = hits.reduce((acc, hit) => {
|
||||
const valuesPaths = expandPath({ data: hit.data, path: valueField });
|
||||
|
@ -362,6 +362,16 @@ describe('Relation widget', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('should default displayFields to valueField', async () => {
|
||||
const field = fromJS(fieldConfig).delete('displayFields');
|
||||
const { getAllByText, input } = setup({ field });
|
||||
fireEvent.keyDown(input, { key: 'ArrowDown' });
|
||||
|
||||
await wait(() => {
|
||||
expect(getAllByText(/^Post # (\d{1,2})$/)).toHaveLength(20);
|
||||
});
|
||||
});
|
||||
|
||||
describe('with multiple', () => {
|
||||
it('should call onChange with correct selectedItem value and metadata', async () => {
|
||||
const field = fromJS({ ...fieldConfig, multiple: true });
|
||||
|
Loading…
x
Reference in New Issue
Block a user