@@ -101,10 +101,9 @@ function Grid() {
101101// ─── InventoryGrid (Embla carousel + dynamic grid) ─────────────────
102102
103103const MAX_DOTS = 5 ;
104- const NAV_HEIGHT = 44 ; // arrows + dots bar
104+ const NAV_HEIGHT = 40 ; // arrows(24px) + gap(8px)
105105/** 다이얼로그 크롬: 제목(50) + 검색(40) + 필터(40) + 패딩/갭(30) + nav(44) */
106106const DIALOG_CHROME_HEIGHT = 204 ;
107- const INLINE_CHROME_HEIGHT = NAV_HEIGHT ;
108107
109108function useInventoryGrid (
110109 totalItems : number ,
@@ -134,17 +133,27 @@ function useInventoryGrid(
134133 if ( width < minItemSize * 2 ) return ;
135134 const nextCols = Math . max ( Math . floor ( ( width + gap ) / ( minItemSize + gap ) ) , 1 ) ;
136135
137- // rows: 뷰포트 높이에서 크롬 높이를 뺀 가용 영역 기반
138- // 실제 아이템 높이를 측정하여 정확한 행 수 계산
139- const firstItem = el . querySelector ( '[class*="grid"] > button' ) ;
140- const measuredHeight = firstItem ? firstItem . getBoundingClientRect ( ) . height : 0 ;
141- const itemHeight = measuredHeight > 0 ? measuredHeight : minItemSize ;
136+ // rows: 가용 높이 기반. 아이템이 aspect-square이므로 컬럼 너비 = 아이템 높이
137+ const colWidth = ( width - ( nextCols - 1 ) * gap ) / nextCols ;
138+ const itemHeight = colWidth ;
142139 const rowHeight = itemHeight + gap ;
143140
144141 const vh = window . innerHeight ;
145- const chrome = mode === 'dialog' ? DIALOG_CHROME_HEIGHT : INLINE_CHROME_HEIGHT ;
146- const dialogHeight = mode === 'dialog' ? vh * 0.9 : vh ;
147- const availableHeight = dialogHeight - chrome ;
142+ let availableHeight : number ;
143+ if ( mode === 'dialog' ) {
144+ availableHeight = vh * 0.9 - DIALOG_CHROME_HEIGHT ;
145+ } else {
146+ // inline: 컨테이너에 flex-1 min-h-0이 설정되어 있으므로
147+ // clientHeight가 부모 flex에 의해 제한된 실제 높이
148+ const containerHeight = el . clientHeight ;
149+ if ( containerHeight > 0 ) {
150+ availableHeight = containerHeight - NAV_HEIGHT ;
151+ } else {
152+ // 초기 렌더링 시 높이가 0일 수 있음 → fallback
153+ const rect = el . getBoundingClientRect ( ) ;
154+ availableHeight = vh - rect . top - NAV_HEIGHT ;
155+ }
156+ }
148157 const nextRows =
149158 availableHeight > 0 ? Math . min ( Math . max ( Math . floor ( availableHeight / rowHeight ) , minRows ) , maxRows ) : minRows ;
150159
@@ -225,11 +234,11 @@ function InventoryGrid({ minRows = 2, maxRows = 10, minItemSize = 64, gap = 4, m
225234 }
226235
227236 return (
228- < div ref = { containerRef } className = "overflow-hidden" >
237+ < div ref = { containerRef } className = "overflow-hidden flex flex-col gap-2 flex-1 min-h-0 " >
229238 { ! ready ? null : (
230239 < >
231240 { /* Navigation: arrows left, dots right */ }
232- < div className = "flex mb-2 justify-between items-center" >
241+ < div className = "flex justify-between items-center" >
233242 < div className = "flex gap-[10px]" >
234243 < PrevButton onClick = { onPrevButtonClick } disabled = { prevBtnDisabled } className = "w-6 h-6" />
235244 < NextButton onClick = { onNextButtonClick } disabled = { nextBtnDisabled } className = "w-6 h-6" />
0 commit comments