File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -45,6 +45,8 @@ export interface ListProps<T> extends React.HTMLAttributes<any> {
45
45
data : T [ ] ;
46
46
height ?: number ;
47
47
itemHeight ?: number ;
48
+ /** If not match virtual scroll condition, Set List still use height of container. */
49
+ fullHeight ?: boolean ;
48
50
itemKey : string | ( ( item : T ) => string ) ;
49
51
component ?: string | React . FC < any > | React . ComponentClass < any > ;
50
52
disabled ?: boolean ;
@@ -706,6 +708,7 @@ class List<T = any> extends React.Component<ListProps<T>, ListState<T>> {
706
708
component : Component = 'div' ,
707
709
height,
708
710
itemHeight,
711
+ fullHeight = true ,
709
712
data,
710
713
children,
711
714
itemKey,
@@ -726,7 +729,11 @@ class List<T = any> extends React.Component<ListProps<T>, ListState<T>> {
726
729
727
730
return (
728
731
< Component
729
- style = { height ? { ...style , height, ...ScrollStyle } : style }
732
+ style = {
733
+ height
734
+ ? { ...style , [ fullHeight ? 'height' : 'maxHeight' ] : height , ...ScrollStyle }
735
+ : style
736
+ }
730
737
className = { mergedClassName }
731
738
{ ...restProps }
732
739
onScroll = { this . onRawScroll }
Original file line number Diff line number Diff line change @@ -29,10 +29,25 @@ describe('List', () => {
29
29
expect ( wrapper . find ( Filler ) . props ( ) . offset ) . toBeFalsy ( ) ;
30
30
} ) ;
31
31
32
- it ( 'height over itemHeight' , ( ) => {
33
- const wrapper = genList ( { data : genData ( 1 ) , itemHeight : 1 , height : 999 } ) ;
32
+ describe ( 'height over itemHeight' , ( ) => {
33
+ it ( 'full height' , ( ) => {
34
+ const wrapper = genList ( { data : genData ( 1 ) , itemHeight : 1 , height : 999 } ) ;
35
+ expect ( wrapper . find ( Filler ) . props ( ) . offset ) . toBeFalsy ( ) ;
36
+ expect ( wrapper . find ( 'ul' ) . props ( ) . style ) . toEqual ( expect . objectContaining ( { height : 999 } ) ) ;
37
+ } ) ;
34
38
35
- expect ( wrapper . find ( Filler ) . props ( ) . offset ) . toBeFalsy ( ) ;
39
+ it ( 'without full height' , ( ) => {
40
+ const wrapper = genList ( {
41
+ data : genData ( 1 ) ,
42
+ itemHeight : 1 ,
43
+ height : 999 ,
44
+ fullHeight : false ,
45
+ } ) ;
46
+ expect ( wrapper . find ( Filler ) . props ( ) . offset ) . toBeFalsy ( ) ;
47
+ expect ( wrapper . find ( 'ul' ) . props ( ) . style ) . toEqual (
48
+ expect . objectContaining ( { maxHeight : 999 } ) ,
49
+ ) ;
50
+ } ) ;
36
51
} ) ;
37
52
} ) ;
38
53
You can’t perform that action at this time.
0 commit comments