mirror of
https://github.com/strapi/strapi.git
synced 2025-09-21 14:31:16 +00:00
Merge pull request #15757 from GitStartHQ/fix/display-order-menuItems-multiple-relations
fix: Sometimes the children display order is incorrect in list view
This commit is contained in:
commit
a6db2ba38c
@ -67,7 +67,7 @@ const RelationMultiple = ({ fieldSchema, metadatas, name, entityId, value, conte
|
|||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
select: (data) => ({
|
select: (data) => ({
|
||||||
...data,
|
...data,
|
||||||
results: data.results.reverse(),
|
results: [...data.results].reverse(),
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@ -17,6 +17,14 @@ jest.mock('@strapi/helper-plugin', () => ({
|
|||||||
id: 1,
|
id: 1,
|
||||||
name: 'Relation entity 1',
|
name: 'Relation entity 1',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'Relation entity 2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: 'Relation entity 3',
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
pagination: {
|
pagination: {
|
||||||
@ -85,4 +93,19 @@ describe('DynamicTable / Cellcontent / RelationMultiple', () => {
|
|||||||
expect(get).toHaveBeenCalledTimes(1);
|
expect(get).toHaveBeenCalledTimes(1);
|
||||||
await waitFor(() => expect(screen.getByText('Relation entity 1')).toBeInTheDocument());
|
await waitFor(() => expect(screen.getByText('Relation entity 1')).toBeInTheDocument());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Displays related entities in reversed order', async () => {
|
||||||
|
const { container } = render(<ComponentFixture />);
|
||||||
|
const button = container.querySelector('[type=button]');
|
||||||
|
|
||||||
|
fireEvent(button, new MouseEvent('mousedown', { bubbles: true }));
|
||||||
|
|
||||||
|
await waitFor(() => {
|
||||||
|
const buttons = screen.getAllByRole('menuitem');
|
||||||
|
|
||||||
|
expect(buttons[1]).toHaveTextContent('Relation entity 3');
|
||||||
|
expect(buttons[2]).toHaveTextContent('Relation entity 2');
|
||||||
|
expect(buttons[3]).toHaveTextContent('Relation entity 1');
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user