Skip to content

Commit 9a0e920

Browse files
authored
Fix plugin sidebar panel rerender issues (#1279)
closes RaspberryPiFoundation/digital-editor-issues#970
1 parent ff4eed9 commit 9a0e920

2 files changed

Lines changed: 25 additions & 17 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## Unreleased
88

9+
### Fixed
10+
11+
- Plugin sidebar panel rerendering (#1279)
12+
913
## [0.34.1] - 2025-11-18
1014

1115
### Fixed

src/components/Menus/Sidebar/Sidebar.jsx

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useEffect, useState } from "react";
1+
import React, { useEffect, useMemo, useState } from "react";
22
import { useTranslation } from "react-i18next";
33
import classNames from "classnames";
44
import { useSelector } from "react-redux";
@@ -80,22 +80,26 @@ const Sidebar = ({ options = [], plugins = [] }) => {
8080
},
8181
].filter((option) => options.includes(option.name));
8282

83-
let pluginMenuOptions = plugins.map((plugin) => {
84-
return {
85-
name: plugin.name,
86-
icon: plugin.icon,
87-
title: plugin.title,
88-
position: plugin.position || "top",
89-
panel: () => (
90-
<SidebarPanel
91-
heading={plugin.heading}
92-
buttons={plugin.buttons ? plugin.buttons() : []}
93-
>
94-
{plugin.panel()}
95-
</SidebarPanel>
96-
),
97-
};
98-
});
83+
let pluginMenuOptions = useMemo(
84+
() =>
85+
plugins.map((plugin) => {
86+
return {
87+
name: plugin.name,
88+
icon: plugin.icon,
89+
title: plugin.title,
90+
position: plugin.position || "top",
91+
panel: () => (
92+
<SidebarPanel
93+
heading={plugin.heading}
94+
buttons={plugin.buttons ? plugin.buttons() : []}
95+
>
96+
{plugin.panel()}
97+
</SidebarPanel>
98+
),
99+
};
100+
}),
101+
[plugins],
102+
);
99103

100104
menuOptions = [...menuOptions, ...pluginMenuOptions];
101105

0 commit comments

Comments
 (0)