Commit 1d4cad1a authored by Joaquim Rocha's avatar Joaquim Rocha
Browse files

frontend: Do not duplicate children in dynamic sidebar items

When items were set up in the sidebar from a plugin, the object they
were using was the one set up in redux. This meant that any children
of that sidebar entry would be appended to the object's "subList" in
redux and hence that list would grow with multiple equal entries
every time the sidebar was rendered.

This patch prevents that by deep cloning the object before using it.
parent 1c96685f
Showing with 3 additions and 1 deletion
+3 -1
import _ from 'lodash';
import { SidebarEntry } from '../../redux/reducers/ui';
import store from '../../redux/stores/store';
......@@ -124,7 +125,8 @@ function prepareRoutes(t: (arg: string) => string) {
// @todo: Find a better way to avoid modifying the objects in LIST_ITEMS.
const routes: SidebarEntry[] = JSON.parse(JSON.stringify(LIST_ITEMS));
for (const item of Object.values(items)) {
for (const i of Object.values(items)) {
const item = _.cloneDeep(i);
const parent = item.parent ? routes.find(({ name }) => name === item.parent) : null;
let placement = routes;
if (parent) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment