@@ -409,6 +409,7 @@ const ProductImageCard: React.FC<ProductImageCardPropType> = ({ language, produc
409409type ProductListStateType = {
410410 openDialog : boolean ;
411411 openBackdrop : boolean ;
412+ resetKey : string ;
412413 product ?: ShopSchemas . Product ;
413414 oneItemOrderData ?: ShopSchemas . CartItemAppendRequest ;
414415} ;
@@ -425,13 +426,18 @@ export const ProductList: React.FC<ShopSchemas.ProductListQueryParams> = (qs) =>
425426 const [ state , setState ] = React . useState < ProductListStateType > ( {
426427 openDialog : false ,
427428 openBackdrop : false ,
429+ resetKey : Math . random ( ) . toString ( 36 ) . substring ( 2 ) ,
428430 } ) ;
429431
432+ const foldAll = ( ) => setState ( ( ps ) => ( { ...ps , resetKey : Math . random ( ) . toString ( 36 ) . substring ( 2 ) } ) ) ;
430433 const openDialog = ( ) => setState ( ( ps ) => ( { ...ps , openDialog : true } ) ) ;
431434 const closeDialog = ( ) => setState ( ( ps ) => ( { ...ps , openDialog : false } ) ) ;
432435 const openBackdrop = ( ) => setState ( ( ps ) => ( { ...ps , openBackdrop : true } ) ) ;
433436 const closeBackdrop = ( ) => setState ( ( ps ) => ( { ...ps , openBackdrop : false } ) ) ;
434437 const setProductDataAndOpenDialog = ( oneItemOrderData : ShopSchemas . CartItemAppendRequest ) => {
438+ // 부모 리렌더링에 따른 form 상태 초기화를 숨기기 위해 accordion을 닫습니다.
439+ // TODO: FIXME: form 상태가 애초에 초기화되면 안됩니다. form 내부 값을 초기화되지 않도록 막고, 접히지 않도록 하세요.
440+ foldAll ( ) ;
435441 setState ( ( ps ) => ( { ...ps , oneItemOrderData } ) ) ;
436442 openDialog ( ) ;
437443 } ;
@@ -470,7 +476,7 @@ export const ProductList: React.FC<ShopSchemas.ProductListQueryParams> = (qs) =>
470476 return (
471477 < >
472478 < CommonComponents . CustomerInfoFormDialog open = { state . openDialog } closeFunc = { closeDialog } onSubmit = { onFormSubmit } />
473- < Common . Components . MDX . OneDetailsOpener >
479+ < Common . Components . MDX . OneDetailsOpener resetKey = { state . resetKey } >
474480 { data . map ( ( p ) => (
475481 < FoldableProductItem
476482 disabled = { oneItemOrderStartMutation . isPending }
0 commit comments