diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 7be4f68f25..ea00a461fb 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -86,13 +86,16 @@ export const getFrontendStore = () => { select: async screenId => { let promise store.update(state => { - const screen = get(allScreens).find(screen => screen._id === screenId) + const screens = get(allScreens) + let selectedScreen = screens.find(screen => screen._id === screenId) + if (!selectedScreen) { + selectedScreen = screens[0] + } state.currentFrontEndType = FrontendTypes.SCREEN - state.currentAssetId = screenId + state.currentAssetId = selectedScreen._id state.currentView = "detail" - - promise = store.actions.screens.regenerateCss(screen) - state.selectedComponentId = screen.props._id + promise = store.actions.screens.regenerateCss(selectedScreen) + state.selectedComponentId = selectedScreen.props._id return state }) await promise