Skip to content

Commit

Permalink
Fix possible NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
mofojed committed Mar 13, 2024
1 parent 35e73c3 commit 1eb4e48
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions plugins/ui/src/js/src/DashboardPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,14 @@ export function DashboardPlugin(
});
// We may need to clean up some panels for this widget if it hasn't actually loaded yet
// We should be able to always be able to do this even if it does load, so just remove any panels from the initial load
const { openWidgets } = initialPluginData;
const openWidget = openWidgets?.[panelId];
if (openWidget?.data?.panelIds != null) {
const { panelIds } = openWidget.data;
for (let i = 0; i < panelIds.length; i += 1) {
LayoutUtils.closeComponent(layout.root, { id: panelIds[i] });
if (initialPluginData != null) {
const { openWidgets } = initialPluginData;
const openWidget = openWidgets?.[panelId];
if (openWidget?.data?.panelIds != null) {
const { panelIds } = openWidget.data;
for (let i = 0; i < panelIds.length; i += 1) {
LayoutUtils.closeComponent(layout.root, { id: panelIds[i] });
}
}
}
},
Expand Down

0 comments on commit 1eb4e48

Please sign in to comment.