diff --git a/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialog.tsx b/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialog.tsx index c0cc75b188..1f6d68179f 100644 --- a/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialog.tsx +++ b/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialog.tsx @@ -89,7 +89,7 @@ export const StepFormDialog: FC = ({ }, [isOpen, onClickBack]) return createPortal( - + = ( const handleCloseAction = useCallback(() => { onClickClose() - setTimeout(() => { - // HINT: ダイアログが閉じるtransitionが完了してから初期化をしている - stepQueue.current = [] - setCurrentStep(firstStep) - }, 300) - }, [firstStep, stepQueue, setCurrentStep, onClickClose]) + }, [onClickClose]) const changeCurrentStep = useCallback( (step: Parameters[0]) => { diff --git a/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialogProvider.tsx b/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialogProvider.tsx index 5cb1050433..44571fa6aa 100644 --- a/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialogProvider.tsx +++ b/packages/smarthr-ui/src/components/Dialog/StepFormDialog/StepFormDialogProvider.tsx @@ -33,11 +33,22 @@ export const StepFormDialogContext = createContext({ type Props = { children: ReactNode firstStep: StepItem + isOpen: boolean } -export const StepFormDialogProvider: FC = ({ children, firstStep }) => { +export const StepFormDialogProvider: FC = ({ children, firstStep, isOpen }) => { const [currentStep, setCurrentStep] = useState(firstStep) const stepQueue = useRef([]) const scrollerRef = useRef(null) + const prevIsOpen = useRef(isOpen) + + // ダイアログが閉じたときにリセット + if (prevIsOpen.current && !isOpen) { + setTimeout(() => { + stepQueue.current = [] + setCurrentStep(firstStep) + }, 300) + } + prevIsOpen.current = isOpen return (