diff --git a/platform/ui/src/contextProviders/ViewportGridProvider.tsx b/platform/ui/src/contextProviders/ViewportGridProvider.tsx index 51e48c2528c..b92d95f1398 100644 --- a/platform/ui/src/contextProviders/ViewportGridProvider.tsx +++ b/platform/ui/src/contextProviders/ViewportGridProvider.tsx @@ -70,7 +70,9 @@ const determineActiveViewportId = (state: DefaultState, newViewports: Map) => { const currentActiveViewport = state.viewports.get(activeViewportId); if (!currentActiveViewport) { - return null; // Return an appropriate value if the current active viewport is not found + // if there is no active viewport, we should just return the first viewport + const firstViewport = newViewports.values().next().value; + return firstViewport.viewportOptions.viewportId; } // for the new viewports, we should rank them by the displaySetInstanceUIDs @@ -257,7 +259,7 @@ export function ViewportGridProvider({ children, service }) { } activeViewportIdToSet = - activeViewportIdToSet ?? determineActiveViewportId(state, viewports) ?? 'default'; + activeViewportIdToSet ?? determineActiveViewportId(state, viewports); const ret = { ...state,