diff --git a/app/client/src/pages/Editor/Explorer/JSActions/JSActionEntity.tsx b/app/client/src/pages/Editor/Explorer/JSActions/JSActionEntity.tsx index d67ee5c9c2..e284a215a7 100644 --- a/app/client/src/pages/Editor/Explorer/JSActions/JSActionEntity.tsx +++ b/app/client/src/pages/Editor/Explorer/JSActions/JSActionEntity.tsx @@ -35,9 +35,11 @@ export const ExplorerJSCollectionEntity = memo( getJSCollection(state, props.id), ) as JSCollection; const navigateToJSCollection = useCallback(() => { - history.push( - JS_COLLECTION_ID_URL(applicationId, pageId, jsAction.id, {}), - ); + if (jsAction.id) { + history.push( + JS_COLLECTION_ID_URL(applicationId, pageId, jsAction.id, {}), + ); + } }, [pageId]); const contextMenu = ( initialState, - [ReduxActionTypes.CREATE_JS_ACTION_INIT]: ( + [ReduxActionTypes.CREATE_JS_ACTION_SUCCESS]: ( state: JSCollectionDataState, action: ReduxAction, ): JSCollectionDataState => state.concat([ { - config: { ...action.payload, id: action.payload.name }, + config: { ...action.payload }, isLoading: false, }, ]), - [ReduxActionTypes.CREATE_JS_ACTION_SUCCESS]: ( - state: JSCollectionDataState, - action: ReduxAction, - ): JSCollectionDataState => - state.map((a) => { - if ( - a.config.pageId === action.payload.pageId && - a.config.id === action.payload.name - ) { - return { ...a, config: action.payload }; - } - return a; - }), [ReduxActionErrorTypes.CREATE_JS_ACTION_ERROR]: ( state: JSCollectionDataState, action: ReduxAction,