@pingux/astro 1.10.0 → 1.10.1-alpha.0

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.
@@ -121,6 +121,7 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
121
121
  isNotFlippable = props.isNotFlippable,
122
122
  direction = props.direction,
123
123
  scrollBoxProps = props.scrollBoxProps,
124
+ controlProps = props.controlProps,
124
125
  defaultFilter = props.defaultFilter;
125
126
  var comboBoxOptions = {
126
127
  children: children,
@@ -238,6 +239,11 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
238
239
  });
239
240
  (0, _utils.useLayoutEffect)(onResize, [onResize]);
240
241
 
242
+ var handleInputOpen = function handleInputOpen(e) {
243
+ if (!state.isOpen && menuTrigger === 'focus') buttonRef.current.click();
244
+ if (controlProps !== null && controlProps !== void 0 && controlProps.onClick) controlProps.onClick(e);
245
+ };
246
+
241
247
  var style = _objectSpread(_objectSpread({}, overlayProps.style), {}, {
242
248
  width: menuWidth,
243
249
  minWidth: menuWidth
@@ -266,7 +272,10 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
266
272
  labelProps: labelProps,
267
273
  inputRef: inputRef,
268
274
  triggerProps: buttonProps,
269
- triggerRef: buttonRef
275
+ triggerRef: buttonRef,
276
+ controlProps: _objectSpread(_objectSpread({}, controlProps), {}, {
277
+ onClick: handleInputOpen
278
+ })
270
279
  })), (0, _react2.jsx)(_PopoverContainer["default"], {
271
280
  isOpen: state.isOpen,
272
281
  ref: popoverRef,
@@ -414,6 +423,11 @@ ComboBoxField.propTypes = {
414
423
  /** @ignore */
415
424
  scrollBoxProps: _propTypes["default"].shape({
416
425
  maxHeight: _propTypes["default"].string
426
+ }),
427
+
428
+ /** Props object that is spread directly into the ComboBoxInput element. */
429
+ controlProps: _propTypes["default"].shape({
430
+ onClick: _propTypes["default"].func
417
431
  })
418
432
  };
419
433
  ComboBoxField.defaultProps = {
@@ -300,6 +300,28 @@ test('should open list on focus when menuTrigger is set to use focus', function
300
300
  expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
301
301
  expect(_testWrapper.screen.queryAllByRole('option')).toHaveLength(items.length);
302
302
  });
303
+ test('should open list on focus on click after selection when menuTrigger is set to use focus', function () {
304
+ getComponent({
305
+ menuTrigger: 'focus'
306
+ });
307
+
308
+ var input = _testWrapper.screen.getByRole('combobox');
309
+
310
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
311
+
312
+ _userEvent["default"].click(input);
313
+
314
+ expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
315
+
316
+ _userEvent["default"].click(_testWrapper.screen.queryAllByRole('option')[0]);
317
+
318
+ expect(_testWrapper.screen.queryByRole('listbox')).not.toBeInTheDocument();
319
+ expect(input).toHaveFocus();
320
+
321
+ _userEvent["default"].click(input);
322
+
323
+ expect(_testWrapper.screen.queryByRole('listbox')).toBeInTheDocument();
324
+ });
303
325
  test('Item accepts a data-id and the data-id can be found in the DOM', function () {
304
326
  getComponent();
305
327
 
@@ -75,6 +75,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
75
75
  isNotFlippable = props.isNotFlippable,
76
76
  direction = props.direction,
77
77
  scrollBoxProps = props.scrollBoxProps,
78
+ controlProps = props.controlProps,
78
79
  defaultFilter = props.defaultFilter;
79
80
  var comboBoxOptions = {
80
81
  children: children,
@@ -192,6 +193,11 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
192
193
  });
193
194
  useLayoutEffect(onResize, [onResize]);
194
195
 
196
+ var handleInputOpen = function handleInputOpen(e) {
197
+ if (!state.isOpen && menuTrigger === 'focus') buttonRef.current.click();
198
+ if (controlProps !== null && controlProps !== void 0 && controlProps.onClick) controlProps.onClick(e);
199
+ };
200
+
195
201
  var style = _objectSpread(_objectSpread({}, overlayProps.style), {}, {
196
202
  width: menuWidth,
197
203
  minWidth: menuWidth
@@ -221,7 +227,10 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
221
227
  labelProps: labelProps,
222
228
  inputRef: inputRef,
223
229
  triggerProps: buttonProps,
224
- triggerRef: buttonRef
230
+ triggerRef: buttonRef,
231
+ controlProps: _objectSpread(_objectSpread({}, controlProps), {}, {
232
+ onClick: handleInputOpen
233
+ })
225
234
  })), ___EmotionJSX(PopoverContainer, {
226
235
  isOpen: state.isOpen,
227
236
  ref: popoverRef,
@@ -369,6 +378,11 @@ ComboBoxField.propTypes = {
369
378
  /** @ignore */
370
379
  scrollBoxProps: PropTypes.shape({
371
380
  maxHeight: PropTypes.string
381
+ }),
382
+
383
+ /** Props object that is spread directly into the ComboBoxInput element. */
384
+ controlProps: PropTypes.shape({
385
+ onClick: PropTypes.func
372
386
  })
373
387
  };
374
388
  ComboBoxField.defaultProps = {
@@ -227,6 +227,20 @@ test('should open list on focus when menuTrigger is set to use focus', function
227
227
  expect(screen.queryByRole('listbox')).toBeInTheDocument();
228
228
  expect(screen.queryAllByRole('option')).toHaveLength(items.length);
229
229
  });
230
+ test('should open list on focus on click after selection when menuTrigger is set to use focus', function () {
231
+ getComponent({
232
+ menuTrigger: 'focus'
233
+ });
234
+ var input = screen.getByRole('combobox');
235
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
236
+ userEvent.click(input);
237
+ expect(screen.queryByRole('listbox')).toBeInTheDocument();
238
+ userEvent.click(screen.queryAllByRole('option')[0]);
239
+ expect(screen.queryByRole('listbox')).not.toBeInTheDocument();
240
+ expect(input).toHaveFocus();
241
+ userEvent.click(input);
242
+ expect(screen.queryByRole('listbox')).toBeInTheDocument();
243
+ });
230
244
  test('Item accepts a data-id and the data-id can be found in the DOM', function () {
231
245
  getComponent();
232
246
  var button = screen.queryByRole('button');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pingux/astro",
3
- "version": "1.10.0",
3
+ "version": "1.10.1-alpha.0",
4
4
  "description": "PingUX themeable React component library",
5
5
  "author": "ux-development@pingidentity.com",
6
6
  "license": "Apache-2.0",