carbon-react 131.0.0 → 131.0.1

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.
@@ -90,8 +90,19 @@ const SelectList = /*#__PURE__*/React.forwardRef(({
90
90
  });
91
91
  const items = virtualizer.getVirtualItems();
92
92
  const childrenList = useMemo(() => React.Children.toArray(children), [children]);
93
+
94
+ // check if object values are equal
95
+ function shallowEqual(objA, objB) {
96
+ const keysA = Object.keys(objA);
97
+ return keysA.every(key => objA[key] === objB[key]);
98
+ }
93
99
  const getIndexOfMatch = useCallback(valueToMatch => {
94
- return childrenList.findIndex(child => /*#__PURE__*/React.isValidElement(child) && child.props.value === valueToMatch);
100
+ return childrenList.findIndex(child => {
101
+ if (child.props.value && typeof valueToMatch === "object") {
102
+ return shallowEqual(child.props.value, valueToMatch);
103
+ }
104
+ return /*#__PURE__*/React.isValidElement(child) && child.props.value === valueToMatch;
105
+ });
95
106
  }, [childrenList]);
96
107
 
97
108
  // getVirtualItems returns an empty array of items if the select list is currently closed - which is correct visually but
@@ -99,8 +99,19 @@ const SelectList = /*#__PURE__*/_react.default.forwardRef(({
99
99
  });
100
100
  const items = virtualizer.getVirtualItems();
101
101
  const childrenList = (0, _react.useMemo)(() => _react.default.Children.toArray(children), [children]);
102
+
103
+ // check if object values are equal
104
+ function shallowEqual(objA, objB) {
105
+ const keysA = Object.keys(objA);
106
+ return keysA.every(key => objA[key] === objB[key]);
107
+ }
102
108
  const getIndexOfMatch = (0, _react.useCallback)(valueToMatch => {
103
- return childrenList.findIndex(child => /*#__PURE__*/_react.default.isValidElement(child) && child.props.value === valueToMatch);
109
+ return childrenList.findIndex(child => {
110
+ if (child.props.value && typeof valueToMatch === "object") {
111
+ return shallowEqual(child.props.value, valueToMatch);
112
+ }
113
+ return /*#__PURE__*/_react.default.isValidElement(child) && child.props.value === valueToMatch;
114
+ });
104
115
  }, [childrenList]);
105
116
 
106
117
  // getVirtualItems returns an empty array of items if the select list is currently closed - which is correct visually but
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-react",
3
- "version": "131.0.0",
3
+ "version": "131.0.1",
4
4
  "description": "A library of reusable React components for easily building user interfaces.",
5
5
  "files": [
6
6
  "lib",