File tree Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Expand file tree Collapse file tree 3 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -59,7 +59,9 @@ export const Cell = memo(
59
59
const cellRef = useRef < HTMLDivElement > ( null ) ;
60
60
61
61
useEffect ( ( ) => {
62
- if ( ! rowAutoHeight ) { return ; }
62
+ if ( ! rowAutoHeight ) {
63
+ return ;
64
+ }
63
65
if ( cellRef . current ) {
64
66
const height = cellRef . current . getBoundingClientRect ( ) . height ;
65
67
updateRowHeight ( rowIndex , height ) ;
Original file line number Diff line number Diff line change @@ -120,31 +120,29 @@ describe("Grid", () => {
120
120
} ) ;
121
121
122
122
it ( "should set row height to default (33px) when rowAutoHeight is false" , async ( ) => {
123
- const { queryByTestId } = renderGrid ( {
123
+ const { getByTestId } = renderGrid ( {
124
124
rowCount : 10 ,
125
125
columnCount : 10 ,
126
126
rowAutoHeight : false ,
127
127
} ) ;
128
128
129
- const cell = queryByTestId ( "row-cell-0-0" ) ;
130
- expect ( cell ) . toBeDefined ( ) ;
129
+ const cell = getByTestId ( "row-cell-0-0" ) ;
131
130
132
- const computedHeight = window . getComputedStyle ( cell ! ) . height ;
131
+ const computedHeight = window . getComputedStyle ( cell ) . height ;
133
132
const heightValue = parseFloat ( computedHeight ) ;
134
133
expect ( heightValue ) . toBe ( 33 ) ;
135
134
} ) ;
136
135
137
136
it ( "should expand row height to 100% when rowAutoHeight is true" , async ( ) => {
138
- const { queryByTestId } = renderGrid ( {
137
+ const { getByTestId } = renderGrid ( {
139
138
rowCount : 1 ,
140
139
columnCount : 1 ,
141
140
rowAutoHeight : true ,
142
141
} ) ;
143
142
144
- const cell = queryByTestId ( "row-cell-0-0" ) ;
145
- expect ( cell ) . toBeDefined ( ) ;
143
+ const cell = getByTestId ( "row-cell-0-0" ) ;
146
144
147
- const computedHeight = window . getComputedStyle ( cell ! ) . height ;
145
+ const computedHeight = window . getComputedStyle ( cell ) . height ;
148
146
expect ( computedHeight ) . toBe ( "100%" ) ;
149
147
} ) ;
150
148
} ) ;
Original file line number Diff line number Diff line change @@ -227,7 +227,9 @@ export const Grid = forwardRef<HTMLDivElement, GridProps>(
227
227
228
228
const updateRowHeight = useCallback (
229
229
( rowIndex : number , height : number ) => {
230
- if ( ! rowAutoHeight ) { return ; }
230
+ if ( ! rowAutoHeight ) {
231
+ return ;
232
+ }
231
233
const prevHeight = rowHeightsRef . current . get ( rowIndex ) ?? 0 ;
232
234
if ( height > prevHeight ) {
233
235
rowHeightsRef . current . set ( rowIndex , height ) ;
You can’t perform that action at this time.
0 commit comments