@carbon/react 1.60.1 → 1.60.2

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.
@@ -198,13 +198,19 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
198
198
  } = changes;
199
199
  switch (type) {
200
200
  case InputBlur:
201
- if (state.inputValue && highlightedIndex == '-1' && !allowCustomValue) {
201
+ if (state.inputValue && highlightedIndex == '-1' && changes.selectedItem) {
202
+ return {
203
+ ...changes,
204
+ inputValue: itemToString(changes.selectedItem)
205
+ };
206
+ } else if (state.inputValue && highlightedIndex == '-1' && !allowCustomValue && !changes.selectedItem) {
202
207
  return {
203
208
  ...changes,
204
209
  inputValue: ''
205
210
  };
211
+ } else {
212
+ return changes;
206
213
  }
207
- return changes;
208
214
  case InputKeyDownEnter:
209
215
  if (allowCustomValue) {
210
216
  setInputValue(inputValue);
@@ -315,7 +321,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
315
321
  setHighlightedIndex
316
322
  } = useCombobox({
317
323
  ...downshiftProps,
318
- items,
324
+ items: filterItems(items, itemToString, inputValue),
319
325
  inputValue: inputValue,
320
326
  itemToString: item => {
321
327
  return itemToString(item);
@@ -418,7 +424,7 @@ const ComboBox = /*#__PURE__*/forwardRef((props, ref) => {
418
424
  if (match(event, Enter) && (!inputValue || allowCustomValue)) {
419
425
  toggleMenu();
420
426
  if (highlightedIndex !== -1) {
421
- selectItem(items[highlightedIndex]);
427
+ selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
422
428
  }
423
429
  event.preventDownshiftDefault = true;
424
430
  event?.persist?.();
@@ -208,13 +208,19 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
208
208
  } = changes;
209
209
  switch (type) {
210
210
  case InputBlur:
211
- if (state.inputValue && highlightedIndex == '-1' && !allowCustomValue) {
211
+ if (state.inputValue && highlightedIndex == '-1' && changes.selectedItem) {
212
+ return {
213
+ ...changes,
214
+ inputValue: itemToString(changes.selectedItem)
215
+ };
216
+ } else if (state.inputValue && highlightedIndex == '-1' && !allowCustomValue && !changes.selectedItem) {
212
217
  return {
213
218
  ...changes,
214
219
  inputValue: ''
215
220
  };
221
+ } else {
222
+ return changes;
216
223
  }
217
- return changes;
218
224
  case InputKeyDownEnter:
219
225
  if (allowCustomValue) {
220
226
  setInputValue(inputValue);
@@ -325,7 +331,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
325
331
  setHighlightedIndex
326
332
  } = Downshift.useCombobox({
327
333
  ...downshiftProps,
328
- items,
334
+ items: filterItems(items, itemToString, inputValue),
329
335
  inputValue: inputValue,
330
336
  itemToString: item => {
331
337
  return itemToString(item);
@@ -428,7 +434,7 @@ const ComboBox = /*#__PURE__*/React.forwardRef((props, ref) => {
428
434
  if (match.match(event, keys.Enter) && (!inputValue || allowCustomValue)) {
429
435
  toggleMenu();
430
436
  if (highlightedIndex !== -1) {
431
- selectItem(items[highlightedIndex]);
437
+ selectItem(filterItems(items, itemToString, inputValue)[highlightedIndex]);
432
438
  }
433
439
  event.preventDownshiftDefault = true;
434
440
  event?.persist?.();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@carbon/react",
3
3
  "description": "React components for the Carbon Design System",
4
- "version": "1.60.1",
4
+ "version": "1.60.2",
5
5
  "license": "Apache-2.0",
6
6
  "main": "lib/index.js",
7
7
  "module": "es/index.js",
@@ -142,5 +142,5 @@
142
142
  "**/*.scss",
143
143
  "**/*.css"
144
144
  ],
145
- "gitHead": "f548182ef995217e7717f9250376ff8995069a09"
145
+ "gitHead": "d9b7c3eaee9e757cb7460d1ff626a1e2211a18fa"
146
146
  }