@@ -213,6 +213,19 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
213
213
onCopyCallback ,
214
214
] ) ;
215
215
216
+ const rowHeightsRef = useRef ( new Map ( ) ) ;
217
+
218
+
219
+ const updateRowHeight = useCallback ( ( rowIndex : number , height : number ) => {
220
+ console . log ( "Updating row height!" ) ;
221
+ const prevHeight = rowHeightsRef . current . get ( rowIndex ) || 0 ;
222
+ if ( height > prevHeight ) {
223
+ rowHeightsRef . current . set ( rowIndex , height ) ;
224
+ gridRef . current ?. resetAfterRowIndex ( rowIndex ) ;
225
+ }
226
+ } , [ ] ) ;
227
+
228
+
216
229
const customOnCopy : ( ) => Promise < void > = useMemo ( ( ) => {
217
230
const result = async ( ) => {
218
231
if ( onCopyProp ) {
@@ -407,6 +420,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
407
420
rowNumberWidth,
408
421
rowStart,
409
422
rowAutoHeight,
423
+ updateRowHeight
410
424
} ;
411
425
412
426
const InnerElementType = forwardRef < HTMLDivElement , InnerElementTypeTypes > (
@@ -758,7 +772,6 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
758
772
const onItemsRendered = useCallback (
759
773
( props : GridOnItemsRenderedProps ) => {
760
774
lastItemsRenderedProps . current = props ;
761
-
762
775
return onItemsRenderedProp ?.( {
763
776
...props ,
764
777
visibleRowStartIndex : props . visibleRowStartIndex + rowStart ,
@@ -794,9 +807,30 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
794
807
useEffect ( ( ) => {
795
808
if ( gridRef . current ) {
796
809
gridRef . current . resetAfterRowIndex ( 0 ) ;
810
+ console . log ( "Inner: " , innerCellRef . current ?. scrollHeight )
811
+ console . log ( "Bounding: " , innerCellRef . current ?. scrollHeight )
797
812
}
798
813
} , [ rowCount ] ) ;
799
814
815
+
816
+ const innerCellRef = useRef < HTMLDivElement > ( null ) ;
817
+
818
+ useEffect ( ( ) => {
819
+ console . log ( "Inner: " , innerCellRef . current ?. getBoundingClientRect ( ) . height )
820
+ if ( innerCellRef . current ) {
821
+ // gridRef.current.resetAfterRowIndex(0);
822
+ console . log ( "Is current" )
823
+ }
824
+ } , [ onItemsRendered ] ) ;
825
+
826
+ const getRowHeight = useCallback ( ( index : number ) => {
827
+ console . log ( `GetRowHeight: from ref: ${ rowHeightsRef . current . get ( index ) } ` )
828
+ return rowHeightsRef . current . get ( index ) || rowHeight ;
829
+ } , [ rowHeight ] ) ;
830
+
831
+
832
+ // console.log("Inner ref? ", innerCellRef.current?.scrollHeight)
833
+ // console.log("Bounding client height? ", innerCellRef.current?.getBoundingClientRect().height)
800
834
return (
801
835
< ContextMenu
802
836
modal = { false }
@@ -831,7 +865,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
831
865
height = { height }
832
866
width = { width }
833
867
columnCount = { columnCount }
834
- rowHeight = { ( ) => rowHeight }
868
+ rowHeight = { getRowHeight }
835
869
useIsScrolling = { useIsScrolling }
836
870
innerElementType = { InnerElementType }
837
871
itemData = { data }
@@ -847,6 +881,7 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
847
881
outerRef = { outerRef }
848
882
outerElementType = { OuterElementType }
849
883
onItemsRendered = { onItemsRendered }
884
+ innerRef = { innerCellRef }
850
885
{ ...props }
851
886
>
852
887
{ CellWithWidth }
0 commit comments