@pingux/astro 1.32.1-alpha.6 → 1.32.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.
@@ -48,6 +48,8 @@ var _focus = require("@react-aria/focus");
48
48
 
49
49
  var _interactions = require("@react-aria/interactions");
50
50
 
51
+ var _utils = require("@react-aria/utils");
52
+
51
53
  var _MenuDownIcon = _interopRequireDefault(require("mdi-react/MenuDownIcon"));
52
54
 
53
55
  var _ = require("../../");
@@ -94,10 +96,16 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
94
96
  wrapperProps = props.wrapperProps,
95
97
  others = (0, _objectWithoutProperties2["default"])(props, _excluded);
96
98
 
97
- var textFieldProps = _objectSpread(_objectSpread(_objectSpread({
99
+ var textFieldProps = _objectSpread({
98
100
  isDisabled: isDisabled,
99
- isReadOnly: isReadOnly
100
- }, controlProps), inputProps), others);
101
+ isReadOnly: isReadOnly,
102
+ containerProps: containerProps
103
+ }, (0, _utils.mergeProps)(inputProps, others)); // istanbul ignore next
104
+
105
+
106
+ (0, _react.useImperativeHandle)(ref, function () {
107
+ return inputRef.current;
108
+ });
101
109
 
102
110
  var _useHover = (0, _interactions.useHover)({}),
103
111
  hoverProps = _useHover.hoverProps,
@@ -167,11 +175,13 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
167
175
  focusRingClass: "focus-ring",
168
176
  autoFocus: hasAutoFocus
169
177
  }, (0, _react2.jsx)(_.Box, (0, _extends2["default"])({
170
- ref: ref,
171
178
  isRow: true,
172
179
  style: style,
173
180
  variant: "forms.comboBox.container"
174
- }, hoverProps, wrapperProps), (0, _react2.jsx)(_.TextField, (0, _extends2["default"])({}, containerProps, textFieldProps, {
181
+ }, hoverProps, wrapperProps), (0, _react2.jsx)(_.TextField, (0, _extends2["default"])({}, textFieldProps, {
182
+ wrapperProps: {
183
+ ref: inputWrapperRef
184
+ },
175
185
  controlProps: _objectSpread({
176
186
  variant: 'forms.comboBox.input'
177
187
  }, controlProps),
@@ -181,9 +191,6 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
181
191
  ref: inputRef,
182
192
  slots: {
183
193
  inContainer: button
184
- },
185
- wrapperProps: {
186
- ref: inputWrapperRef
187
194
  }
188
195
  }))));
189
196
  });
@@ -247,11 +247,6 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
247
247
  });
248
248
  (0, _utils.useLayoutEffect)(onResize, [onResize]);
249
249
 
250
- var handleInputOpen = function handleInputOpen(e) {
251
- if (!state.isOpen && menuTrigger === 'focus') buttonRef.current.click();
252
- if (controlProps !== null && controlProps !== void 0 && controlProps.onClick) controlProps.onClick(e);
253
- };
254
-
255
250
  var style = _objectSpread(_objectSpread({}, overlayProps.style), {}, {
256
251
  width: menuWidth,
257
252
  minWidth: menuWidth
@@ -282,16 +277,16 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
282
277
  inputRef: inputRef,
283
278
  triggerProps: buttonProps,
284
279
  triggerRef: buttonRef,
285
- controlProps: _objectSpread(_objectSpread({}, controlProps), {}, {
286
- onClick: handleInputOpen
287
- })
280
+ controlProps: controlProps
288
281
  })), (0, _react2.jsx)(_PopoverContainer["default"], {
282
+ hasNoArrow: true,
283
+ isDismissable: true,
284
+ isNonModal: true,
289
285
  isOpen: state.isOpen,
290
- ref: popoverRef,
286
+ onClose: state.close,
291
287
  placement: placement,
292
- hasNoArrow: true,
293
- style: style,
294
- isNonModal: true
288
+ ref: popoverRef,
289
+ style: style
295
290
  }, listbox));
296
291
  });
297
292
  ComboBoxField.propTypes = _objectSpread({
@@ -354,7 +354,7 @@ test('should open list on focus when menuTrigger is set to use focus', function
354
354
  expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
355
355
  expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(items.length);
356
356
  });
357
- test('should open list on focus on click after selection when menuTrigger is set to use focus', function () {
357
+ test('should open list on click after selection when menuTrigger is set to use focus', function () {
358
358
  getComponent({
359
359
  menuTrigger: 'focus'
360
360
  });
@@ -370,7 +370,9 @@ test('should open list on focus on click after selection when menuTrigger is set
370
370
  _userEvent["default"].click(_testWrapper.screen.queryAllByRole('option')[0]);
371
371
 
372
372
  expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
373
- expect(input).toHaveFocus();
373
+ expect(input).toHaveFocus(); // Need to click away first, then click back
374
+
375
+ _userEvent["default"].click(document.body);
374
376
 
375
377
  _userEvent["default"].click(input);
376
378
 
@@ -498,7 +500,7 @@ test('should invoke onSelectionChange when selection is made', function () {
498
500
 
499
501
  expect(onSelectionChange).toHaveBeenNthCalledWith(1, items[2].id); // Should fire when input is cleared
500
502
 
501
- _userEvent["default"].type(input, '{selectall}{backspace}');
503
+ _userEvent["default"].clear(input);
502
504
 
503
505
  expect(onSelectionChange).toHaveBeenNthCalledWith(2, null); // Should fire on keyboard interaction
504
506
 
@@ -1008,9 +1010,9 @@ test('two listbox can not be open at the same time', function () {
1008
1010
  expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(3);
1009
1011
  expect(_testWrapper.screen.queryByRole('option', {
1010
1012
  name: 'Aardvark'
1011
- })).toBeInTheDocument();
1013
+ })).toBeInTheDocument(); // first click closes first popover, second click opens the second popover
1012
1014
 
1013
- _userEvent["default"].click(button2);
1015
+ _userEvent["default"].dblClick(button2);
1014
1016
 
1015
1017
  expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
1016
1018
  expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(2);
@@ -1130,4 +1132,24 @@ test('should have no accessibility violations', /*#__PURE__*/(0, _asyncToGenerat
1130
1132
  }
1131
1133
  }
1132
1134
  }, _callee5);
1133
- })));
1135
+ })));
1136
+ test('popover closes on input blur', function () {
1137
+ getComponent();
1138
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
1139
+ expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
1140
+
1141
+ var input = _testWrapper.screen.getByRole('combobox');
1142
+
1143
+ _userEvent["default"].click(input);
1144
+
1145
+ expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
1146
+ expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(3);
1147
+ expect(_testWrapper.screen.queryByRole('option', {
1148
+ name: 'Aardvark'
1149
+ })).toBeInTheDocument();
1150
+
1151
+ _userEvent["default"].click(document.body);
1152
+
1153
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
1154
+ expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
1155
+ });
@@ -159,14 +159,13 @@ test('should upload a file if label clicked', /*#__PURE__*/(0, _asyncToGenerator
159
159
  }
160
160
  }, _callee2);
161
161
  })));
162
- test('should show the menu if label clicked when preview image exists', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
163
- var imageUploadLabel, imagePreview;
162
+ test('should show the menu if image preview is clicked when preview image exists', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
163
+ var imagePreview;
164
164
  return _regenerator["default"].wrap(function _callee3$(_context3) {
165
165
  while (1) {
166
166
  switch (_context3.prev = _context3.next) {
167
167
  case 0:
168
168
  getComponent();
169
- imageUploadLabel = _testWrapper.screen.getByText(testLabel);
170
169
 
171
170
  _react2.fireEvent.change(_testWrapper.screen.getByTestId('image-upload-input'), {
172
171
  target: {
@@ -174,20 +173,20 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
174
173
  }
175
174
  });
176
175
 
177
- _context3.next = 5;
176
+ _context3.next = 4;
178
177
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
179
178
 
180
- case 5:
179
+ case 4:
181
180
  imagePreview = _context3.sent;
182
181
  expect(imagePreview).toBeInTheDocument();
183
- expect(imagePreview).toHaveAttribute('src');
182
+ expect(imagePreview).toHaveAttribute('src'); // Click on the image preview button
184
183
 
185
- _userEvent["default"].click(imageUploadLabel);
184
+ _userEvent["default"].click(_testWrapper.screen.getByRole('button'));
186
185
 
187
186
  expect(_testWrapper.screen.getByText('Upload New Image')).toBeInTheDocument();
188
187
  expect(_testWrapper.screen.getByText('Remove Image')).toBeInTheDocument();
189
188
 
190
- case 11:
189
+ case 10:
191
190
  case "end":
192
191
  return _context3.stop();
193
192
  }
@@ -404,8 +403,8 @@ test('loader size can be changed via the prop', function () {
404
403
  'font-size': "".concat(testLoaderSize, "px")
405
404
  });
406
405
  });
407
- test('should show the menu if label clicked when preview image exists', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
408
- var customUploadProp, customRemoveProp, imageUploadLabel, imagePreview;
406
+ test('should show the menu if label clicked when preview image exists with custom uploads', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
407
+ var customUploadProp, customRemoveProp, imagePreview;
409
408
  return _regenerator["default"].wrap(function _callee6$(_context6) {
410
409
  while (1) {
411
410
  switch (_context6.prev = _context6.next) {
@@ -416,7 +415,6 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
416
415
  uploadItemText: customUploadProp,
417
416
  removeItemText: customRemoveProp
418
417
  });
419
- imageUploadLabel = _testWrapper.screen.getByText(testLabel);
420
418
 
421
419
  _react2.fireEvent.change(_testWrapper.screen.getByTestId('image-upload-input'), {
422
420
  target: {
@@ -424,20 +422,20 @@ test('should show the menu if label clicked when preview image exists', /*#__PUR
424
422
  }
425
423
  });
426
424
 
427
- _context6.next = 7;
425
+ _context6.next = 6;
428
426
  return _testWrapper.screen.findByTestId(imageUploadImagePreview);
429
427
 
430
- case 7:
428
+ case 6:
431
429
  imagePreview = _context6.sent;
432
430
  expect(imagePreview).toBeInTheDocument();
433
- expect(imagePreview).toHaveAttribute('src');
431
+ expect(imagePreview).toHaveAttribute('src'); // Click on the image preview button
434
432
 
435
- _userEvent["default"].click(imageUploadLabel);
433
+ _userEvent["default"].click(_testWrapper.screen.getByRole('button'));
436
434
 
437
435
  expect(_testWrapper.screen.getByText(customUploadProp)).toBeInTheDocument();
438
436
  expect(_testWrapper.screen.getByText(customRemoveProp)).toBeInTheDocument();
439
437
 
440
- case 13:
438
+ case 12:
441
439
  case "end":
442
440
  return _context6.stop();
443
441
  }
@@ -480,11 +480,13 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
480
480
  }, ariaProps, inputProps)), helperText && (0, _react2.jsx)(_.FieldHelperText, {
481
481
  status: status
482
482
  }, helperText), (0, _react2.jsx)(_.PopoverContainer, {
483
- ref: popoverRef,
484
483
  hasNoArrow: true,
484
+ isDismissable: true,
485
485
  isNonModal: true,
486
486
  isOpen: isOpen,
487
+ onClose: close,
487
488
  placement: placement,
489
+ ref: popoverRef,
488
490
  style: style
489
491
  }, listbox));
490
492
  });
@@ -95,7 +95,9 @@ test('opens listbox on focus and fires "onFocus', function () {
95
95
 
96
96
  var input = _testWrapper.screen.getByRole('combobox');
97
97
 
98
- input.focus();
98
+ _userEvent["default"].tab();
99
+
100
+ expect(input).toHaveFocus();
99
101
  expect(_testWrapper.screen.getByRole('listbox')).toBeInTheDocument();
100
102
 
101
103
  var options = _testWrapper.screen.getAllByRole('option');
@@ -112,7 +114,9 @@ test('closes listbox on blur and fires "onBlur"', function () {
112
114
 
113
115
  var input = _testWrapper.screen.getByRole('combobox');
114
116
 
115
- input.focus();
117
+ _userEvent["default"].tab();
118
+
119
+ expect(input).toHaveFocus();
116
120
  expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
117
121
  input.blur();
118
122
  expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
@@ -126,7 +130,9 @@ test('opening and closing listbox fires "onOpenChange"', function () {
126
130
 
127
131
  var input = _testWrapper.screen.getByRole('combobox');
128
132
 
129
- input.focus();
133
+ _userEvent["default"].tab();
134
+
135
+ expect(input).toHaveFocus();
130
136
  expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
131
137
  expect(onOpenChange).toHaveBeenCalledWith(true);
132
138
  input.blur();
@@ -138,7 +144,9 @@ test('multiple selection is enabled, option disappears after selection', functio
138
144
 
139
145
  var input = _testWrapper.screen.getByRole('combobox');
140
146
 
141
- input.focus();
147
+ _userEvent["default"].tab();
148
+
149
+ expect(input).toHaveFocus();
142
150
 
143
151
  var listbox = _testWrapper.screen.getByRole('listbox');
144
152
 
@@ -156,7 +164,9 @@ test('clicking an option renders chip with option name', function () {
156
164
 
157
165
  var input = _testWrapper.screen.getByRole('combobox');
158
166
 
159
- input.focus();
167
+ _userEvent["default"].tab();
168
+
169
+ expect(input).toHaveFocus();
160
170
 
161
171
  var options = _testWrapper.screen.getAllByRole('option');
162
172
 
@@ -175,7 +185,9 @@ test('clicking on delete button deletes selection, and re-adds option to list',
175
185
 
176
186
  var input = _testWrapper.screen.getByRole('combobox');
177
187
 
178
- input.focus();
188
+ _userEvent["default"].tab();
189
+
190
+ expect(input).toHaveFocus();
179
191
 
180
192
  var options = _testWrapper.screen.getAllByRole('option');
181
193
 
@@ -189,7 +201,10 @@ test('clicking on delete button deletes selection, and re-adds option to list',
189
201
  var deleteButton = chip.nextSibling;
190
202
  deleteButton.click();
191
203
  expect(chip).not.toBeInTheDocument();
192
- input.focus();
204
+
205
+ _userEvent["default"].tab();
206
+
207
+ expect(input).toHaveFocus();
193
208
 
194
209
  var updatedOptions = _testWrapper.screen.getAllByRole('option');
195
210
 
@@ -204,7 +219,9 @@ test('clicking an option fires "onSelectionChange"', function () {
204
219
 
205
220
  var input = _testWrapper.screen.getByRole('combobox');
206
221
 
207
- input.focus();
222
+ _userEvent["default"].tab();
223
+
224
+ expect(input).toHaveFocus();
208
225
 
209
226
  var listbox = _testWrapper.screen.getByRole('listbox');
210
227
 
@@ -335,7 +352,9 @@ test('in non-restrictive mode the value that was already selected using the list
335
352
 
336
353
  var input = _testWrapper.screen.getByRole('combobox');
337
354
 
338
- input.focus();
355
+ _userEvent["default"].tab();
356
+
357
+ expect(input).toHaveFocus();
339
358
 
340
359
  var listbox = _testWrapper.screen.getByRole('listbox');
341
360
 
@@ -357,7 +376,9 @@ test('options can be focused via keyboard', function () {
357
376
 
358
377
  var input = _testWrapper.screen.getByRole('combobox');
359
378
 
360
- input.focus();
379
+ _userEvent["default"].tab();
380
+
381
+ expect(input).toHaveFocus();
361
382
 
362
383
  var listbox = _testWrapper.screen.getByRole('listbox');
363
384
 
@@ -381,7 +402,9 @@ test('options can be selected via keyboard', function () {
381
402
 
382
403
  var input = _testWrapper.screen.getByRole('combobox');
383
404
 
384
- input.focus();
405
+ _userEvent["default"].tab();
406
+
407
+ expect(input).toHaveFocus();
385
408
 
386
409
  var listbox = _testWrapper.screen.getByRole('listbox');
387
410
 
@@ -527,4 +550,24 @@ test('read only keys with read only field', function () {
527
550
 
528
551
  expect(textArea).toHaveClass('is-read-only');
529
552
  expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
553
+ });
554
+ test('popover closes on input blur', function () {
555
+ getComponent();
556
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
557
+ expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
558
+
559
+ var input = _testWrapper.screen.getByRole('combobox');
560
+
561
+ _userEvent["default"].click(input);
562
+
563
+ expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
564
+ expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(3);
565
+ expect(_testWrapper.screen.queryByRole('option', {
566
+ name: 'Aardvark'
567
+ })).toBeInTheDocument();
568
+
569
+ _userEvent["default"].click(document.body);
570
+
571
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
572
+ expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
530
573
  });
@@ -129,7 +129,7 @@ var PopoverWrapper = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
129
129
  });
130
130
 
131
131
  var _useOverlay = (0, _overlays.useOverlay)(_objectSpread(_objectSpread({}, props), {}, {
132
- isDismissable: isDismissable && isOpen
132
+ shouldCloseOnBlur: !isNotClosedOnBlur
133
133
  }), popoverRef),
134
134
  overlayProps = _useOverlay.overlayProps;
135
135
 
@@ -494,4 +494,24 @@ test('should have no accessibility violations', /*#__PURE__*/(0, _asyncToGenerat
494
494
  }
495
495
  }
496
496
  }, _callee);
497
- })));
497
+ })));
498
+ test('popover closes on button blur', function () {
499
+ getComponent();
500
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
501
+ expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
502
+
503
+ var button = _testWrapper.screen.getByRole('button');
504
+
505
+ _userEvent["default"].click(button);
506
+
507
+ expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
508
+ expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(3);
509
+ expect(_testWrapper.screen.queryByRole('option', {
510
+ name: 'a'
511
+ })).toBeInTheDocument();
512
+
513
+ _userEvent["default"].click(document.body);
514
+
515
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
516
+ expect(_testWrapper.screen.queryByRole('option')).not.toBeInTheDocument();
517
+ });
@@ -240,14 +240,14 @@ var useSelectField = function useSelectField(props, ref) {
240
240
  }
241
241
  }));
242
242
  var overlay = (0, _react2.jsx)(_PopoverContainer["default"], {
243
- isOpen: state.isOpen,
244
- ref: popoverRef,
245
- placement: placement,
246
243
  hasNoArrow: true,
247
- onClose: state.close,
248
- style: style,
244
+ isDismissable: true,
249
245
  isNonModal: true,
250
- isDismissable: true
246
+ isOpen: state.isOpen,
247
+ onClose: state.close,
248
+ placement: placement,
249
+ ref: popoverRef,
250
+ style: style
251
251
  }, (0, _react2.jsx)(_ScrollBox["default"], scrollBoxProps, listbox));
252
252
  return {
253
253
  columnStyleProps: columnStyleProps,
@@ -170,12 +170,8 @@ var Row = /*#__PURE__*/(0, _react.memo)(function (props) {
170
170
  sx: sx.comboBoxField
171
171
  },
172
172
  containerProps: {
173
- 'aria-label': 'selection field',
174
173
  width: '100%',
175
- maxWidth: '310px',
176
- sx: {
177
- width: '100%'
178
- }
174
+ maxWidth: '310px'
179
175
  },
180
176
  inputValue: inputValue,
181
177
  onInputChange: setInputValue
@@ -18,10 +18,11 @@ function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (
18
18
 
19
19
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context, _context2; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context = ownKeys(Object(source), !0)).call(_context, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context2 = ownKeys(Object(source))).call(_context2, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
20
20
 
21
- import React, { forwardRef, useEffect, useRef, useState } from 'react';
21
+ import React, { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';
22
22
  import PropTypes from 'prop-types';
23
23
  import { FocusRing } from '@react-aria/focus';
24
24
  import { PressResponder, useHover } from '@react-aria/interactions';
25
+ import { mergeProps } from '@react-aria/utils';
25
26
  import MenuDown from 'mdi-react/MenuDownIcon';
26
27
  import { Box, Button, Icon, Loader, TextField } from '../../';
27
28
  import { ariaAttributesBasePropTypes } from '../../utils/devUtils/props/ariaAttributes';
@@ -51,10 +52,16 @@ var ComboBoxInput = /*#__PURE__*/forwardRef(function (props, ref) {
51
52
  wrapperProps = props.wrapperProps,
52
53
  others = _objectWithoutProperties(props, _excluded);
53
54
 
54
- var textFieldProps = _objectSpread(_objectSpread(_objectSpread({
55
+ var textFieldProps = _objectSpread({
55
56
  isDisabled: isDisabled,
56
- isReadOnly: isReadOnly
57
- }, controlProps), inputProps), others);
57
+ isReadOnly: isReadOnly,
58
+ containerProps: containerProps
59
+ }, mergeProps(inputProps, others)); // istanbul ignore next
60
+
61
+
62
+ useImperativeHandle(ref, function () {
63
+ return inputRef.current;
64
+ });
58
65
 
59
66
  var _useHover = useHover({}),
60
67
  hoverProps = _useHover.hoverProps,
@@ -126,11 +133,13 @@ var ComboBoxInput = /*#__PURE__*/forwardRef(function (props, ref) {
126
133
  focusRingClass: "focus-ring",
127
134
  autoFocus: hasAutoFocus
128
135
  }, ___EmotionJSX(Box, _extends({
129
- ref: ref,
130
136
  isRow: true,
131
137
  style: style,
132
138
  variant: "forms.comboBox.container"
133
- }, hoverProps, wrapperProps), ___EmotionJSX(TextField, _extends({}, containerProps, textFieldProps, {
139
+ }, hoverProps, wrapperProps), ___EmotionJSX(TextField, _extends({}, textFieldProps, {
140
+ wrapperProps: {
141
+ ref: inputWrapperRef
142
+ },
134
143
  controlProps: _objectSpread({
135
144
  variant: 'forms.comboBox.input'
136
145
  }, controlProps),
@@ -140,9 +149,6 @@ var ComboBoxInput = /*#__PURE__*/forwardRef(function (props, ref) {
140
149
  ref: inputRef,
141
150
  slots: {
142
151
  inContainer: button
143
- },
144
- wrapperProps: {
145
- ref: inputWrapperRef
146
152
  }
147
153
  }))));
148
154
  });
@@ -199,11 +199,6 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
199
199
  });
200
200
  useLayoutEffect(onResize, [onResize]);
201
201
 
202
- var handleInputOpen = function handleInputOpen(e) {
203
- if (!state.isOpen && menuTrigger === 'focus') buttonRef.current.click();
204
- if (controlProps !== null && controlProps !== void 0 && controlProps.onClick) controlProps.onClick(e);
205
- };
206
-
207
202
  var style = _objectSpread(_objectSpread({}, overlayProps.style), {}, {
208
203
  width: menuWidth,
209
204
  minWidth: menuWidth
@@ -235,16 +230,16 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
235
230
  inputRef: inputRef,
236
231
  triggerProps: buttonProps,
237
232
  triggerRef: buttonRef,
238
- controlProps: _objectSpread(_objectSpread({}, controlProps), {}, {
239
- onClick: handleInputOpen
240
- })
233
+ controlProps: controlProps
241
234
  })), ___EmotionJSX(PopoverContainer, {
235
+ hasNoArrow: true,
236
+ isDismissable: true,
237
+ isNonModal: true,
242
238
  isOpen: state.isOpen,
243
- ref: popoverRef,
239
+ onClose: state.close,
244
240
  placement: placement,
245
- hasNoArrow: true,
246
- style: style,
247
- isNonModal: true
241
+ ref: popoverRef,
242
+ style: style
248
243
  }, listbox));
249
244
  });
250
245
  ComboBoxField.propTypes = _objectSpread({
@@ -278,7 +278,7 @@ test('should open list on focus when menuTrigger is set to use focus', function
278
278
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
279
279
  expect(screen.queryAllByRole('option')).toHaveLength(items.length);
280
280
  });
281
- test('should open list on focus on click after selection when menuTrigger is set to use focus', function () {
281
+ test('should open list on click after selection when menuTrigger is set to use focus', function () {
282
282
  getComponent({
283
283
  menuTrigger: 'focus'
284
284
  });
@@ -288,7 +288,9 @@ test('should open list on focus on click after selection when menuTrigger is set
288
288
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
289
289
  userEvent.click(screen.queryAllByRole('option')[0]);
290
290
  expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
291
- expect(input).toHaveFocus();
291
+ expect(input).toHaveFocus(); // Need to click away first, then click back
292
+
293
+ userEvent.click(document.body);
292
294
  userEvent.click(input);
293
295
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
294
296
  });
@@ -385,7 +387,7 @@ test('should invoke onSelectionChange when selection is made', function () {
385
387
  userEvent.click(screen.queryAllByRole('option')[2]);
386
388
  expect(onSelectionChange).toHaveBeenNthCalledWith(1, items[2].id); // Should fire when input is cleared
387
389
 
388
- userEvent.type(input, '{selectall}{backspace}');
390
+ userEvent.clear(input);
389
391
  expect(onSelectionChange).toHaveBeenNthCalledWith(2, null); // Should fire on keyboard interaction
390
392
 
391
393
  userEvent.type(input, '{arrowdown}{enter}');
@@ -835,8 +837,9 @@ test('two listbox can not be open at the same time', function () {
835
837
  expect(screen.queryAllByRole('option')).toHaveLength(3);
836
838
  expect(screen.queryByRole('option', {
837
839
  name: 'Aardvark'
838
- })).toBeInTheDocument();
839
- userEvent.click(button2);
840
+ })).toBeInTheDocument(); // first click closes first popover, second click opens the second popover
841
+
842
+ userEvent.dblClick(button2);
840
843
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
841
844
  expect(screen.queryAllByRole('option')).toHaveLength(2);
842
845
  expect(screen.queryByRole('option', {
@@ -931,4 +934,19 @@ test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator(
931
934
  }
932
935
  }
933
936
  }, _callee5);
934
- })));
937
+ })));
938
+ test('popover closes on input blur', function () {
939
+ getComponent();
940
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
941
+ expect(screen.queryByRole('option')).not.toBeInTheDocument();
942
+ var input = screen.getByRole('combobox');
943
+ userEvent.click(input);
944
+ expect(screen.queryByRole('listbox')).toBeInTheDocument();
945
+ expect(screen.queryAllByRole('option')).toHaveLength(3);
946
+ expect(screen.queryByRole('option', {
947
+ name: 'Aardvark'
948
+ })).toBeInTheDocument();
949
+ userEvent.click(document.body);
950
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
951
+ expect(screen.queryByRole('option')).not.toBeInTheDocument();
952
+ });