@jetbrains/ring-ui 7.0.78 → 7.0.79
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
CHANGED
|
@@ -84,10 +84,18 @@ export default class List extends Component {
|
|
|
84
84
|
const { data, activeIndex, restoreActiveIndex } = nextProps;
|
|
85
85
|
const nextState = { prevActiveIndex: activeIndex, prevData: data };
|
|
86
86
|
if (data !== prevData) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
87
|
+
// Only clear activeIndex if it's out of bounds OR the item at that position changed
|
|
88
|
+
const currentActiveIndex = prevState.activeIndex;
|
|
89
|
+
const currentActiveItem = prevState.activeItem;
|
|
90
|
+
if (currentActiveIndex !== null &&
|
|
91
|
+
(currentActiveIndex >= data.length ||
|
|
92
|
+
!data[currentActiveIndex] ||
|
|
93
|
+
(currentActiveItem && data[currentActiveIndex].key !== currentActiveItem.key))) {
|
|
94
|
+
Object.assign(nextState, {
|
|
95
|
+
activeIndex: null,
|
|
96
|
+
activeItem: null,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
91
99
|
}
|
|
92
100
|
if (activeIndex !== null && activeIndex !== undefined && activeIndex !== prevActiveIndex && data[activeIndex]) {
|
|
93
101
|
Object.assign(nextState, {
|