fix(widget-relation): fix displayFields default (#3783)
This commit is contained in:
@ -155,7 +155,7 @@ export default class RelationControl extends React.Component {
|
|||||||
parseHitOptions = hits => {
|
parseHitOptions = hits => {
|
||||||
const { field } = this.props;
|
const { field } = this.props;
|
||||||
const valueField = field.get('valueField');
|
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 options = hits.reduce((acc, hit) => {
|
||||||
const valuesPaths = expandPath({ data: hit.data, path: valueField });
|
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', () => {
|
describe('with multiple', () => {
|
||||||
it('should call onChange with correct selectedItem value and metadata', async () => {
|
it('should call onChange with correct selectedItem value and metadata', async () => {
|
||||||
const field = fromJS({ ...fieldConfig, multiple: true });
|
const field = fromJS({ ...fieldConfig, multiple: true });
|
||||||
|
Reference in New Issue
Block a user