Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const StepFormDialog: FC<Props> = ({
}, [isOpen, onClickBack])

return createPortal(
<StepFormDialogProvider firstStep={firstStep}>
<StepFormDialogProvider firstStep={firstStep} isOpen={isOpen}>
<DialogContentInner
{...rest}
isOpen={isOpen}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,7 @@ export const StepFormDialogContentInner: FC<StepFormDialogContentInnerProps> = (

const handleCloseAction = useCallback(() => {
onClickClose()
setTimeout(() => {
// HINT: ダイアログが閉じるtransitionが完了してから初期化をしている
stepQueue.current = []
setCurrentStep(firstStep)
}, 300)
}, [firstStep, stepQueue, setCurrentStep, onClickClose])
}, [onClickClose])

const changeCurrentStep = useCallback(
(step: Parameters<typeof setCurrentStep>[0]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,22 @@ export const StepFormDialogContext = createContext<StepFormDialogContextType>({
type Props = {
children: ReactNode
firstStep: StepItem
isOpen: boolean
}
export const StepFormDialogProvider: FC<Props> = ({ children, firstStep }) => {
export const StepFormDialogProvider: FC<Props> = ({ children, firstStep, isOpen }) => {
const [currentStep, setCurrentStep] = useState<StepItem>(firstStep)
const stepQueue = useRef<StepItem[]>([])
const scrollerRef = useRef<HTMLDivElement>(null)
const prevIsOpen = useRef(isOpen)

// ダイアログが閉じたときにリセット
if (prevIsOpen.current && !isOpen) {
setTimeout(() => {
stepQueue.current = []
setCurrentStep(firstStep)
}, 300)
}
prevIsOpen.current = isOpen

return (
<StepFormDialogContext.Provider value={{ currentStep, stepQueue, setCurrentStep, scrollerRef }}>
Expand Down
Loading