From 1eb4e48c3cb5c1f90305e7a928018c54b36b21c4 Mon Sep 17 00:00:00 2001 From: mikebender Date: Wed, 13 Mar 2024 13:29:45 -0400 Subject: [PATCH] Fix possible NPE --- plugins/ui/src/js/src/DashboardPlugin.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/ui/src/js/src/DashboardPlugin.tsx b/plugins/ui/src/js/src/DashboardPlugin.tsx index 352ecbd83..33cad703e 100644 --- a/plugins/ui/src/js/src/DashboardPlugin.tsx +++ b/plugins/ui/src/js/src/DashboardPlugin.tsx @@ -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] }); + } } } },