@pingux/astro 2.57.0-alpha.6 → 2.57.0-alpha.7

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.
@@ -255,17 +255,17 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
255
255
  selectionManager.toggleSelection(selectionManager.focusedKey);
256
256
  setFilterString('');
257
257
  }
258
- } else if (hasCustomValue && filteredItems.length === 1) {
259
- selectTheOnlyFilteredItem();
260
- } else if (!hasCustomValue) {
261
- setFilterString('');
262
- close();
263
- } else if (hasCustomValue) {
258
+ } else if (hasCustomValue && !selectionManager.focusedKey) {
264
259
  var _key = e.target.value;
265
260
  if (_key === '') {
266
261
  return;
267
262
  }
268
263
  addNewBadgeFromInput(e.target.value);
264
+ } else if (hasCustomValue && filteredItems.length === 1) {
265
+ selectTheOnlyFilteredItem();
266
+ } else if (!hasCustomValue) {
267
+ setFilterString('');
268
+ close();
269
269
  }
270
270
  break;
271
271
  }
@@ -703,6 +703,36 @@ test('should clear the input text onBlur and enter when a single filter result i
703
703
  });
704
704
  expect(input).toHaveValue('');
705
705
  });
706
+ test('in non-restrictive mode the partial string values should be accepted', function () {
707
+ var itemsWithDuplicatePartialString = [{
708
+ id: 1,
709
+ name: 'echo:read',
710
+ key: 'echo:read'
711
+ }, {
712
+ id: 2,
713
+ name: 'echo:write',
714
+ key: 'echo:write'
715
+ }, {
716
+ id: 3,
717
+ name: 'echo:delete',
718
+ key: 'echo:delete'
719
+ }];
720
+ getComponent({
721
+ mode: 'non-restrictive',
722
+ items: itemsWithDuplicatePartialString
723
+ });
724
+ var input = _testWrapper.screen.getByRole('combobox');
725
+ expect(input).toHaveValue('');
726
+ var value = 'echo:r';
727
+ _userEvent["default"].type(input, value);
728
+ _userEvent["default"].type(input, '{enter}');
729
+ expect(input).toHaveValue('');
730
+ expect(_testWrapper.screen.queryByText(value)).toBeInTheDocument();
731
+ _userEvent["default"].type(input, value);
732
+ _userEvent["default"].type(input, '{enter}');
733
+ expect(input).not.toHaveValue('');
734
+ expect(input).toHaveValue(value);
735
+ });
706
736
 
707
737
  // Needs to be added to each components test file
708
738
  (0, _universalComponentTest.universalComponentTests)({
@@ -243,17 +243,17 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
243
243
  selectionManager.toggleSelection(selectionManager.focusedKey);
244
244
  setFilterString('');
245
245
  }
246
- } else if (hasCustomValue && filteredItems.length === 1) {
247
- selectTheOnlyFilteredItem();
248
- } else if (!hasCustomValue) {
249
- setFilterString('');
250
- close();
251
- } else if (hasCustomValue) {
246
+ } else if (hasCustomValue && !selectionManager.focusedKey) {
252
247
  var _key = e.target.value;
253
248
  if (_key === '') {
254
249
  return;
255
250
  }
256
251
  addNewBadgeFromInput(e.target.value);
252
+ } else if (hasCustomValue && filteredItems.length === 1) {
253
+ selectTheOnlyFilteredItem();
254
+ } else if (!hasCustomValue) {
255
+ setFilterString('');
256
+ close();
257
257
  }
258
258
  break;
259
259
  }
@@ -700,6 +700,36 @@ test('should clear the input text onBlur and enter when a single filter result i
700
700
  });
701
701
  expect(input).toHaveValue('');
702
702
  });
703
+ test('in non-restrictive mode the partial string values should be accepted', function () {
704
+ var itemsWithDuplicatePartialString = [{
705
+ id: 1,
706
+ name: 'echo:read',
707
+ key: 'echo:read'
708
+ }, {
709
+ id: 2,
710
+ name: 'echo:write',
711
+ key: 'echo:write'
712
+ }, {
713
+ id: 3,
714
+ name: 'echo:delete',
715
+ key: 'echo:delete'
716
+ }];
717
+ getComponent({
718
+ mode: 'non-restrictive',
719
+ items: itemsWithDuplicatePartialString
720
+ });
721
+ var input = screen.getByRole('combobox');
722
+ expect(input).toHaveValue('');
723
+ var value = 'echo:r';
724
+ userEvent.type(input, value);
725
+ userEvent.type(input, '{enter}');
726
+ expect(input).toHaveValue('');
727
+ expect(screen.queryByText(value)).toBeInTheDocument();
728
+ userEvent.type(input, value);
729
+ userEvent.type(input, '{enter}');
730
+ expect(input).not.toHaveValue('');
731
+ expect(input).toHaveValue(value);
732
+ });
703
733
 
704
734
  // Needs to be added to each components test file
705
735
  universalComponentTests({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "2.57.0-alpha.6",
3
+ "version": "2.57.0-alpha.7",
4
4
  "description": "React component library for Ping Identity's design system",
5
5
  "repository": {
6
6
  "type": "git",