carbon-react 133.0.3 → 133.0.4
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.
|
@@ -335,7 +335,10 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
335
335
|
});
|
|
336
336
|
}, [childrenList, filterText, getIndexOfMatch, virtualizer]);
|
|
337
337
|
useEffect(() => {
|
|
338
|
-
if
|
|
338
|
+
// remove the current selected option if the value is cleared
|
|
339
|
+
// this prevents it from remaining highlighted when the list is re-opened
|
|
340
|
+
if ((!highlightedValue || Object.keys(highlightedValue).length === 0) && !isOpen) {
|
|
341
|
+
setCurrentOptionsListIndex(-1);
|
|
339
342
|
return;
|
|
340
343
|
}
|
|
341
344
|
const indexOfMatch = getIndexOfMatch(highlightedValue);
|
|
@@ -343,7 +346,7 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
|
|
|
343
346
|
return;
|
|
344
347
|
}
|
|
345
348
|
setCurrentOptionsListIndex(indexOfMatch);
|
|
346
|
-
}, [getIndexOfMatch, highlightedValue]);
|
|
349
|
+
}, [getIndexOfMatch, highlightedValue, isOpen]);
|
|
347
350
|
|
|
348
351
|
// ensure that the currently-selected option is always visible immediately after
|
|
349
352
|
// it has been changed
|
|
@@ -344,7 +344,10 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
344
344
|
});
|
|
345
345
|
}, [childrenList, filterText, getIndexOfMatch, virtualizer]);
|
|
346
346
|
(0, _react.useEffect)(() => {
|
|
347
|
-
if
|
|
347
|
+
// remove the current selected option if the value is cleared
|
|
348
|
+
// this prevents it from remaining highlighted when the list is re-opened
|
|
349
|
+
if ((!highlightedValue || Object.keys(highlightedValue).length === 0) && !isOpen) {
|
|
350
|
+
setCurrentOptionsListIndex(-1);
|
|
348
351
|
return;
|
|
349
352
|
}
|
|
350
353
|
const indexOfMatch = getIndexOfMatch(highlightedValue);
|
|
@@ -352,7 +355,7 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
|
|
|
352
355
|
return;
|
|
353
356
|
}
|
|
354
357
|
setCurrentOptionsListIndex(indexOfMatch);
|
|
355
|
-
}, [getIndexOfMatch, highlightedValue]);
|
|
358
|
+
}, [getIndexOfMatch, highlightedValue, isOpen]);
|
|
356
359
|
|
|
357
360
|
// ensure that the currently-selected option is always visible immediately after
|
|
358
361
|
// it has been changed
|