diff --git a/apps/builder/src/page/App/components/Actions/ActionPanel/PanelHeader/index.tsx b/apps/builder/src/page/App/components/Actions/ActionPanel/PanelHeader/index.tsx index 58b8d64a42..e489350321 100644 --- a/apps/builder/src/page/App/components/Actions/ActionPanel/PanelHeader/index.tsx +++ b/apps/builder/src/page/App/components/Actions/ActionPanel/PanelHeader/index.tsx @@ -2,6 +2,7 @@ import { ILLA_MIXPANEL_BUILDER_PAGE_NAME, MixpanelTrackProvider, } from "@illa-public/mixpanel-utils" +import { getInitialContent } from "@illa-public/public-configs" import { Resource } from "@illa-public/public-types" import { ACTION_MODAL_WIDTH, @@ -13,7 +14,11 @@ import { FC, useState } from "react" import { useTranslation } from "react-i18next" import { useDispatch, useSelector } from "react-redux" import { Modal, Space, TriggerProvider } from "@illa-design/react" -import { getCachedAction } from "@/redux/config/configSelector" +import { + getCachedAction, + getSelectedAction, +} from "@/redux/config/configSelector" +import { configActions } from "@/redux/config/configSlice" import { getAllResources } from "@/redux/resource/resourceSelector" import { resourceActions } from "@/redux/resource/resourceSlice" import { track } from "@/utils/mixpanelHelper" @@ -33,6 +38,8 @@ const PanelHeader: FC = () => { const resourceList = useSelector(getAllResources) const action = useSelector(getCachedAction)!! + const selectedAction = useSelector(getSelectedAction)!! + const dispatch = useDispatch() const createOrUpdateResourceCallback = ( @@ -40,10 +47,22 @@ const PanelHeader: FC = () => { isUpdate: boolean, ) => { setEditorVisible(false) + setGeneratorVisible(false) if (isUpdate) { dispatch(resourceActions.updateResourceItemReducer(resource)) } else { dispatch(resourceActions.addResourceItemReducer(resource)) + dispatch( + configActions.updateCachedAction({ + ...action, + actionType: resource.resourceType, + resourceID: resource.resourceID, + content: + selectedAction.actionType === resource.resourceType + ? selectedAction.content + : getInitialContent(resource.resourceType), + }), + ) } } diff --git a/apps/builder/src/page/App/components/DotPanel/hooks/sectionUtils.ts b/apps/builder/src/page/App/components/DotPanel/hooks/sectionUtils.ts index 5c732f7052..4d93c127ba 100644 --- a/apps/builder/src/page/App/components/DotPanel/hooks/sectionUtils.ts +++ b/apps/builder/src/page/App/components/DotPanel/hooks/sectionUtils.ts @@ -1,7 +1,7 @@ export const getCurrentDisplayName = ( sectionViewConfigs: any[], viewSortedKey: string[], - defaultViewKey: string, + defaultViewPath: string, isProduction: boolean, viewPath: string | undefined, currentViewIndex: number, @@ -9,7 +9,7 @@ export const getCurrentDisplayName = ( if (!Array.isArray(sectionViewConfigs) || !Array.isArray(viewSortedKey)) return "sub-page1" const defaultedViewConfig = sectionViewConfigs.find( - (item) => item.key === defaultViewKey, + (item) => item.path === defaultViewPath, ) const defaultedViewKey = viewSortedKey.includes( defaultedViewConfig?.viewDisplayName,