@jetbrains/ring-ui 4.2.5 → 4.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/list/list.js +20 -11
- package/package.json +2 -2
package/components/list/list.js
CHANGED
|
@@ -178,17 +178,8 @@ export default class List extends Component {
|
|
|
178
178
|
document.addEventListener('mousemove', this.onDocumentMouseMove);
|
|
179
179
|
document.addEventListener('keydown', this.onDocumentKeyDown, true);
|
|
180
180
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
if (activeIndex == null && shouldActivateFirstItem(this.props)) {
|
|
184
|
-
const firstActivatableIndex = data.findIndex(isActivatable);
|
|
185
|
-
if (firstActivatableIndex >= 0) {
|
|
186
|
-
this.setState({
|
|
187
|
-
activeIndex: firstActivatableIndex,
|
|
188
|
-
activeItem: data[firstActivatableIndex],
|
|
189
|
-
needScrollToActive: true
|
|
190
|
-
});
|
|
191
|
-
}
|
|
181
|
+
if (this.props.activeIndex == null && shouldActivateFirstItem(this.props)) {
|
|
182
|
+
this.activateFirst();
|
|
192
183
|
}
|
|
193
184
|
}
|
|
194
185
|
|
|
@@ -202,6 +193,13 @@ export default class List extends Component {
|
|
|
202
193
|
this.virtualizedList.recomputeRowHeights();
|
|
203
194
|
}
|
|
204
195
|
|
|
196
|
+
if (this.props.activeIndex == null &&
|
|
197
|
+
this.props.data !== prevProps.data &&
|
|
198
|
+
shouldActivateFirstItem(this.props)
|
|
199
|
+
) {
|
|
200
|
+
this.activateFirst();
|
|
201
|
+
}
|
|
202
|
+
|
|
205
203
|
this.checkOverflow();
|
|
206
204
|
}
|
|
207
205
|
|
|
@@ -277,6 +275,17 @@ export default class List extends Component {
|
|
|
277
275
|
return this._hasActivatableItems(this.props.data);
|
|
278
276
|
}
|
|
279
277
|
|
|
278
|
+
activateFirst = () => {
|
|
279
|
+
const firstActivatableIndex = this.props.data.findIndex(isActivatable);
|
|
280
|
+
if (firstActivatableIndex >= 0) {
|
|
281
|
+
this.setState({
|
|
282
|
+
activeIndex: firstActivatableIndex,
|
|
283
|
+
activeItem: this.props.data[firstActivatableIndex],
|
|
284
|
+
needScrollToActive: true
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
|
|
280
289
|
selectHandler = memoize(index => (event, tryKeepOpen = false) => {
|
|
281
290
|
const item = this.props.data[index];
|
|
282
291
|
if (!this.props.useMouseUp && item.onClick) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jetbrains/ring-ui",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.6",
|
|
4
4
|
"description": "JetBrains UI library",
|
|
5
5
|
"author": "JetBrains",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -221,5 +221,5 @@
|
|
|
221
221
|
"node": ">=7.4",
|
|
222
222
|
"npm": ">=6.0.0"
|
|
223
223
|
},
|
|
224
|
-
"gitHead": "
|
|
224
|
+
"gitHead": "2859a8356ddd35e59398fb36699866f786126b2a"
|
|
225
225
|
}
|