diff --git a/app/src/organisms/ChooseProtocolSlideout/index.tsx b/app/src/organisms/ChooseProtocolSlideout/index.tsx index 6a1c1a0aa8c..6f00082013a 100644 --- a/app/src/organisms/ChooseProtocolSlideout/index.tsx +++ b/app/src/organisms/ChooseProtocolSlideout/index.tsx @@ -331,6 +331,15 @@ export function ChooseProtocolSlideoutComponent( } }) ?? null + const resetRunTimeParameters = (): void => { + setRunTimeParametersOverrides( + runTimeParametersOverrides?.map(parameter => ({ + ...parameter, + value: parameter.default, + })) + ) + } + const pageTwoBody = ( @@ -339,13 +348,7 @@ export function ChooseProtocolSlideoutComponent( css={ isRestoreDefaultsLinkEnabled ? ENABLED_LINK_CSS : DISABLED_LINK_CSS } - onClick={() => { - const clone = runTimeParametersOverrides.map(parameter => ({ - ...parameter, - value: parameter.default, - })) - setRunTimeParametersOverrides(clone) - }} + onClick={resetRunTimeParameters} paddingBottom={SPACING.spacing10} {...targetProps} > @@ -408,7 +411,11 @@ export function ChooseProtocolSlideoutComponent( return ( { + onCloseClick() + setCurrentPage(1) + resetRunTimeParameters() + }} currentStep={currentPage} maxSteps={hasRunTimeParameters ? 2 : 1} title={t('choose_protocol_to_run', { name })} diff --git a/app/src/organisms/ChooseRobotSlideout/index.tsx b/app/src/organisms/ChooseRobotSlideout/index.tsx index 520cc0ed7c6..fd77056db76 100644 --- a/app/src/organisms/ChooseRobotSlideout/index.tsx +++ b/app/src/organisms/ChooseRobotSlideout/index.tsx @@ -113,6 +113,7 @@ interface ChooseRobotSlideoutProps showIdleOnly?: boolean multiSlideout?: { currentPage: number } | null setHasParamError?: (isError: boolean) => void + resetRunTimeParameters?: () => void } export function ChooseRobotSlideout( @@ -139,6 +140,7 @@ export function ChooseRobotSlideout( runTimeParametersOverrides, setRunTimeParametersOverrides, setHasParamError, + resetRunTimeParameters, } = props const dispatch = useDispatch() @@ -507,15 +509,7 @@ export function ChooseRobotSlideout( ? ENABLED_LINK_CSS : DISABLED_LINK_CSS } - onClick={() => { - const clone = runTimeParametersOverrides.map(parameter => ({ - ...parameter, - value: parameter.default, - })) - if (setRunTimeParametersOverrides != null) { - setRunTimeParametersOverrides(clone) - } - }} + onClick={() => resetRunTimeParameters?.()} paddingBottom={SPACING.spacing10} {...targetProps} > diff --git a/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx b/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx index 8ef332adaa3..17e64b4fb6b 100644 --- a/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx +++ b/app/src/organisms/ChooseRobotToRunProtocolSlideout/index.tsx @@ -132,6 +132,8 @@ export function ChooseRobotToRunProtocolSlideoutComponent( 'downgrade', ].includes(autoUpdateAction) + const hasRunTimeParameters = runTimeParameters.length > 0 + if ( protocolKey == null || srcFileNames == null || @@ -174,7 +176,14 @@ export function ChooseRobotToRunProtocolSlideoutComponent( ) - const hasRunTimeParameters = runTimeParameters.length > 0 + const resetRunTimeParameters = (): void => { + setRunTimeParametersOverrides( + runTimeParametersOverrides?.map(parameter => ({ + ...parameter, + value: parameter.default, + })) + ) + } return ( { + onCloseClick() + resetRunTimeParameters() + setCurrentPage(1) + setSelectedRobot(null) + }} title={ hasRunTimeParameters && currentPage === 2 ? t('select_parameters_for_robot', { @@ -250,8 +264,9 @@ export function ChooseRobotToRunProtocolSlideoutComponent( reset={resetCreateRun} runCreationError={runCreationError} runCreationErrorCode={runCreationErrorCode} - showIdleOnly={true} + showIdleOnly setHasParamError={setHasParamError} + resetRunTimeParameters={resetRunTimeParameters} /> ) }