1
+ import 'react-virtualized/styles.css' ;
1
2
import * as React from '@theia/core/shared/react' ;
2
3
import AutoSizer from 'react-virtualized/dist/commonjs/AutoSizer' ;
3
4
import {
@@ -43,7 +44,7 @@ export class ComponentList<T extends ArduinoComponent> extends React.Component<
43
44
constructor ( props : ComponentList . Props < T > ) {
44
45
super ( props ) ;
45
46
this . cache = new CellMeasurerCache ( {
46
- defaultHeight : 300 ,
47
+ defaultHeight : 140 ,
47
48
fixedWidth : true ,
48
49
} ) ;
49
50
}
@@ -59,14 +60,19 @@ export class ComponentList<T extends ArduinoComponent> extends React.Component<
59
60
this . mostRecentWidth = width ;
60
61
return (
61
62
< List
62
- className = { ' items-container' }
63
+ className = " items-container"
63
64
rowRenderer = { this . createItem }
64
65
height = { height }
65
66
width = { width }
66
67
rowCount = { this . props . items . length }
67
68
rowHeight = { this . cache . rowHeight }
68
69
deferredMeasurementCache = { this . cache }
69
70
ref = { this . setListRef }
71
+ estimatedRowSize = { 140 }
72
+ // If default value, then `react-virtualized` will optimize and list item will not receive a `:hover` event.
73
+ // Hence, install and version `<select>` won't be visible even if the mouse cursor is over the `<div>`.
74
+ // See https://github.com/bvaughn/react-virtualized/blob/005be24a608add0344284053dae7633be86053b2/source/Grid/Grid.js#L38-L42
75
+ scrollingResetTimeInterval = { 0 }
70
76
/>
71
77
) ;
72
78
} }
@@ -83,7 +89,7 @@ export class ComponentList<T extends ArduinoComponent> extends React.Component<
83
89
}
84
90
}
85
91
86
- private setListRef = ( ref : List | null ) : void => {
92
+ private readonly setListRef = ( ref : List | null ) : void => {
87
93
this . list = ref || undefined ;
88
94
} ;
89
95
@@ -101,14 +107,21 @@ export class ComponentList<T extends ArduinoComponent> extends React.Component<
101
107
private clear ( index : number ) : void {
102
108
this . cache . clear ( index , 0 ) ;
103
109
this . list ?. recomputeRowHeights ( index ) ;
104
- // Update the last item if the if the one before was updated
105
- if ( index === this . props . items . length - 2 ) {
106
- this . cache . clear ( index + 1 , 0 ) ;
107
- this . list ?. recomputeRowHeights ( index + 1 ) ;
110
+ // The last item need extra space height for the footer on hover.
111
+ if ( index === this . props . items . length - 1 ) {
112
+ this . list ?. recomputeGridSize ( ) ;
113
+ // Scroll to the very end if the last item has the :hover, so that footer will be visible.
114
+ const endPosition = this . list ?. getOffsetForRow ( {
115
+ index,
116
+ alignment : 'end' ,
117
+ } ) ;
118
+ if ( endPosition ) {
119
+ this . list ?. scrollToPosition ( endPosition ) ;
120
+ }
108
121
}
109
122
}
110
123
111
- private createItem : ListRowRenderer = ( {
124
+ private readonly createItem : ListRowRenderer = ( {
112
125
index,
113
126
parent,
114
127
key,
0 commit comments