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
}
@@ -67,6 +68,11 @@ export class ComponentList<T extends ArduinoComponent> extends React.Component<
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,22 @@ 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 needs extra space for the footer on :hover.
111
+ if ( index === this . props . items . length - 1 ) {
112
+ // First, recompute the grid size
113
+ this . list ?. recomputeGridSize ( ) ;
114
+ // Then, scroll to the very end of the list so that the footer will be visible. (#1387)
115
+ const endPosition = this . list ?. getOffsetForRow ( {
116
+ index,
117
+ alignment : 'end' ,
118
+ } ) ;
119
+ if ( endPosition ) {
120
+ this . list ?. scrollToPosition ( endPosition ) ;
121
+ }
108
122
}
109
123
}
110
124
111
- private createItem : ListRowRenderer = ( {
125
+ private readonly createItem : ListRowRenderer = ( {
112
126
index,
113
127
parent,
114
128
key,
0 commit comments