@pingux/astro 1.21.0-alpha.2 → 1.21.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.
- package/CHANGELOG.md +17 -0
- package/lib/cjs/components/ComboBox/ComboBoxInput.js +6 -1
- package/lib/cjs/components/ComboBoxField/ComboBoxField.js +7 -5
- package/lib/cjs/components/ComboBoxField/ComboBoxField.test.js +77 -18
- package/lib/components/ComboBox/ComboBoxInput.js +6 -1
- package/lib/components/ComboBoxField/ComboBoxField.js +7 -5
- package/lib/components/ComboBoxField/ComboBoxField.test.js +59 -8
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -3,6 +3,23 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
5
5
|
|
6
|
+
# [1.21.0](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.20.0...@pingux/astro@1.21.0) (2022-06-24)
|
7
|
+
|
8
|
+
|
9
|
+
### Bug Fixes
|
10
|
+
|
11
|
+
* [UIP-5521] Incorrect Chips Styles in MultivaluesField When Wrapped in Box ([ee302fb](https://gitlab.corp.pingidentity.com/ux/pingux/commit/ee302fb2f0cc6d9ff3503fbdba3be2a560bd7d9b))
|
12
|
+
|
13
|
+
|
14
|
+
### Features
|
15
|
+
|
16
|
+
* [UIP-5373] ListView A11Y Improvement ([b4df30c](https://gitlab.corp.pingidentity.com/ux/pingux/commit/b4df30c1b90de4f34b7036e9c552380fd345a1cd))
|
17
|
+
* [UIP-5457] reduce height of MultivaluesField ([30e9c83](https://gitlab.corp.pingidentity.com/ux/pingux/commit/30e9c83fdb681114646f5401d1780e4077115e2b))
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
|
6
23
|
# [1.20.0](https://gitlab.corp.pingidentity.com/ux/pingux/compare/@pingux/astro@1.19.0...@pingux/astro@1.20.0) (2022-06-21)
|
7
24
|
|
8
25
|
|
@@ -62,7 +62,7 @@ var _Loader = _interopRequireDefault(require("../Loader"));
|
|
62
62
|
|
63
63
|
var _react2 = require("@emotion/react");
|
64
64
|
|
65
|
-
var _excluded = ["controlProps", "containerProps", "hasAutoFocus", "helperText", "isDisabled", "isReadOnly", "isOpen", "label", "labelProps", "loadingState", "status", "style", "inputRef", "inputProps", "triggerRef", "triggerProps", "menuTrigger", "onInputChange", "onLoadMore", "onOpenChange", "onSelectionChange", "wrapperProps"];
|
65
|
+
var _excluded = ["controlProps", "containerProps", "hasAutoFocus", "helperText", "isDisabled", "isReadOnly", "isOpen", "label", "labelProps", "loadingState", "status", "style", "inputWrapperRef", "inputRef", "inputProps", "triggerRef", "triggerProps", "menuTrigger", "onInputChange", "onLoadMore", "onOpenChange", "onSelectionChange", "wrapperProps"];
|
66
66
|
|
67
67
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
68
68
|
|
@@ -85,6 +85,7 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
85
85
|
loadingState = props.loadingState,
|
86
86
|
status = props.status,
|
87
87
|
style = props.style,
|
88
|
+
inputWrapperRef = props.inputWrapperRef,
|
88
89
|
inputRef = props.inputRef,
|
89
90
|
inputProps = props.inputProps,
|
90
91
|
triggerRef = props.triggerRef,
|
@@ -188,6 +189,9 @@ var ComboBoxInput = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
188
189
|
ref: inputRef,
|
189
190
|
slots: {
|
190
191
|
inContainer: button
|
192
|
+
},
|
193
|
+
wrapperProps: {
|
194
|
+
ref: inputWrapperRef
|
191
195
|
}
|
192
196
|
}))));
|
193
197
|
});
|
@@ -203,6 +207,7 @@ ComboBoxInput.propTypes = {
|
|
203
207
|
label: _propTypes["default"].node,
|
204
208
|
labelProps: _propTypes["default"].shape({}),
|
205
209
|
loadingState: _propTypes["default"].oneOf((0, _values["default"])(_loadingStates["default"])),
|
210
|
+
inputWrapperRef: _propTypes["default"].shape({}),
|
206
211
|
inputRef: _propTypes["default"].shape({}),
|
207
212
|
triggerProps: _propTypes["default"].shape({}),
|
208
213
|
triggerRef: _propTypes["default"].shape({}),
|
@@ -160,6 +160,7 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
160
160
|
var buttonRef = (0, _react.useRef)();
|
161
161
|
var listBoxRef = (0, _react.useRef)();
|
162
162
|
var inputRef = (0, _react.useRef)();
|
163
|
+
var inputWrapperRef = (0, _react.useRef)();
|
163
164
|
(0, _hooks.usePropWarning)(props, 'disabled', 'isDisabled');
|
164
165
|
/* istanbul ignore next */
|
165
166
|
|
@@ -228,7 +229,7 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
228
229
|
otherListBoxProps = (0, _objectWithoutProperties2["default"])(listBoxProps, _excluded);
|
229
230
|
|
230
231
|
var _useOverlayPosition = (0, _overlays.useOverlayPosition)({
|
231
|
-
targetRef:
|
232
|
+
targetRef: inputWrapperRef,
|
232
233
|
overlayRef: popoverRef,
|
233
234
|
scrollRef: listBoxRef,
|
234
235
|
placement: "".concat(direction, " end"),
|
@@ -259,12 +260,12 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
259
260
|
|
260
261
|
var onResize = (0, _react.useCallback)(function () {
|
261
262
|
/* istanbul ignore next */
|
262
|
-
if (
|
263
|
-
setMenuWidth(
|
263
|
+
if (inputWrapperRef.current) {
|
264
|
+
setMenuWidth(inputWrapperRef.current.offsetWidth);
|
264
265
|
}
|
265
|
-
}, [
|
266
|
+
}, [inputWrapperRef, setMenuWidth]);
|
266
267
|
(0, _utils.useResizeObserver)({
|
267
|
-
ref:
|
268
|
+
ref: inputWrapperRef,
|
268
269
|
onResize: onResize
|
269
270
|
});
|
270
271
|
(0, _utils.useLayoutEffect)(onResize, [onResize]);
|
@@ -300,6 +301,7 @@ var ComboBoxField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref) {
|
|
300
301
|
isOpen: state.isOpen,
|
301
302
|
inputProps: inputProps,
|
302
303
|
labelProps: labelProps,
|
304
|
+
inputWrapperRef: inputWrapperRef,
|
303
305
|
inputRef: inputRef,
|
304
306
|
triggerProps: buttonProps,
|
305
307
|
triggerRef: buttonRef,
|
@@ -46,6 +46,8 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime-corejs3/helpers/e
|
|
46
46
|
|
47
47
|
var _react = _interopRequireWildcard(require("react"));
|
48
48
|
|
49
|
+
var _react2 = require("@testing-library/react");
|
50
|
+
|
49
51
|
var _jestAxe = require("jest-axe");
|
50
52
|
|
51
53
|
var _i18n = require("@react-aria/i18n");
|
@@ -58,7 +60,7 @@ var _index = require("../../index");
|
|
58
60
|
|
59
61
|
var _loadingStates = _interopRequireDefault(require("../../utils/devUtils/constants/loadingStates"));
|
60
62
|
|
61
|
-
var
|
63
|
+
var _react3 = require("@emotion/react");
|
62
64
|
|
63
65
|
function _getRequireWildcardCache(nodeInterop) { if (typeof _WeakMap !== "function") return null; var cacheBabelInterop = new _WeakMap(); var cacheNodeInterop = new _WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
64
66
|
|
@@ -66,7 +68,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
66
68
|
|
67
69
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty2(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
68
70
|
|
69
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
71
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty2(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty2(_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
70
72
|
|
71
73
|
var items = [{
|
72
74
|
name: 'Aardvark',
|
@@ -90,8 +92,8 @@ var getComponent = function getComponent() {
|
|
90
92
|
_ref$renderFn = _ref.renderFn,
|
91
93
|
renderFn = _ref$renderFn === void 0 ? _testWrapper.render : _ref$renderFn;
|
92
94
|
|
93
|
-
return renderFn((0,
|
94
|
-
return (0,
|
95
|
+
return renderFn((0, _react3.jsx)(_index.OverlayProvider, null, (0, _react3.jsx)(_index.ComboBoxField, (0, _extends2["default"])({}, defaultProps, props), function (item) {
|
96
|
+
return (0, _react3.jsx)(_index.Item, (0, _extends2["default"])({}, item, {
|
95
97
|
key: item.id,
|
96
98
|
"data-id": item.name
|
97
99
|
}), item.name);
|
@@ -114,12 +116,12 @@ var ComboBoxWithCustomFilter = function ComboBoxWithCustomFilter() {
|
|
114
116
|
return startsWith(item.name, filterValue);
|
115
117
|
});
|
116
118
|
}, [startsWith, filterValue]);
|
117
|
-
return (0,
|
119
|
+
return (0, _react3.jsx)(_index.ComboBoxField, (0, _extends2["default"])({}, defaultProps, {
|
118
120
|
items: filteredItems,
|
119
121
|
inputValue: filterValue,
|
120
122
|
onInputChange: setFilterValue
|
121
123
|
}), function (item) {
|
122
|
-
return (0,
|
124
|
+
return (0, _react3.jsx)(_index.Item, {
|
123
125
|
id: item.id
|
124
126
|
}, item.name);
|
125
127
|
});
|
@@ -158,7 +160,7 @@ var ComboBoxWithAddOption = function ComboBoxWithAddOption() {
|
|
158
160
|
setSelectedKey(key);
|
159
161
|
};
|
160
162
|
|
161
|
-
return (0,
|
163
|
+
return (0, _react3.jsx)(_index.ComboBoxField, {
|
162
164
|
label: "Example label",
|
163
165
|
defaultItems: options,
|
164
166
|
inputValue: inputValue,
|
@@ -167,7 +169,7 @@ var ComboBoxWithAddOption = function ComboBoxWithAddOption() {
|
|
167
169
|
onSelectionChange: onSelectionChange,
|
168
170
|
hasAddOption: true
|
169
171
|
}, function (item) {
|
170
|
-
return (0,
|
172
|
+
return (0, _react3.jsx)(_index.Item, {
|
171
173
|
key: item.name
|
172
174
|
}, item.name);
|
173
175
|
});
|
@@ -530,7 +532,7 @@ test('should be able to use controlled filtering', /*#__PURE__*/(0, _asyncToGene
|
|
530
532
|
while (1) {
|
531
533
|
switch (_context2.prev = _context2.next) {
|
532
534
|
case 0:
|
533
|
-
(0, _testWrapper.render)((0,
|
535
|
+
(0, _testWrapper.render)((0, _react3.jsx)(ComboBoxWithCustomFilter, null));
|
534
536
|
input = _testWrapper.screen.queryByRole('combobox'); // Should list all without filterable input
|
535
537
|
|
536
538
|
_userEvent["default"].type(input, '{arrowdown}');
|
@@ -637,6 +639,63 @@ test('should show in input "textValue" if provided', /*#__PURE__*/(0, _asyncToGe
|
|
637
639
|
}
|
638
640
|
}, _callee3);
|
639
641
|
})));
|
642
|
+
test('option list should be opened on scroll input value', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
643
|
+
var options, otherItems, input;
|
644
|
+
return _regenerator["default"].wrap(function _callee4$(_context5) {
|
645
|
+
while (1) {
|
646
|
+
switch (_context5.prev = _context5.next) {
|
647
|
+
case 0:
|
648
|
+
otherItems = [{
|
649
|
+
name: 'Short item name one',
|
650
|
+
id: '1'
|
651
|
+
}, {
|
652
|
+
name: 'Short item name two',
|
653
|
+
id: '2'
|
654
|
+
}, {
|
655
|
+
name: 'Short item name three',
|
656
|
+
id: '3'
|
657
|
+
}, {
|
658
|
+
name: 'This is very very very long item name',
|
659
|
+
id: '4'
|
660
|
+
}];
|
661
|
+
getComponent({
|
662
|
+
defaultItems: otherItems
|
663
|
+
});
|
664
|
+
input = _testWrapper.screen.queryByRole('combobox');
|
665
|
+
|
666
|
+
_userEvent["default"].type(input, '{arrowdown}');
|
667
|
+
|
668
|
+
options = _testWrapper.screen.queryAllByRole('option');
|
669
|
+
expect(options).toHaveLength(otherItems.length);
|
670
|
+
|
671
|
+
_userEvent["default"].type(input, 'This is very very very long item name');
|
672
|
+
|
673
|
+
_react2.fireEvent.scroll(input, {
|
674
|
+
target: {
|
675
|
+
scrollX: 10
|
676
|
+
}
|
677
|
+
});
|
678
|
+
|
679
|
+
options = _testWrapper.screen.queryAllByRole('option');
|
680
|
+
expect(options.length).toBe(1);
|
681
|
+
expect(options[0]).toHaveTextContent(otherItems[3].name);
|
682
|
+
|
683
|
+
_react2.fireEvent.scroll(window, {
|
684
|
+
target: {
|
685
|
+
scrollX: 10
|
686
|
+
}
|
687
|
+
});
|
688
|
+
|
689
|
+
options = _testWrapper.screen.queryAllByRole('option');
|
690
|
+
expect(options.length).toBe(0);
|
691
|
+
|
692
|
+
case 14:
|
693
|
+
case "end":
|
694
|
+
return _context5.stop();
|
695
|
+
}
|
696
|
+
}
|
697
|
+
}, _callee4);
|
698
|
+
})));
|
640
699
|
describe('loadingState', function () {
|
641
700
|
it('combobox should not render a loader if menu is not open', function () {
|
642
701
|
var _getComponent = getComponent({
|
@@ -1004,7 +1063,7 @@ test('onSelectionChange works properly with custom value', function () {
|
|
1004
1063
|
expect(onSelectionChange).toHaveBeenCalledWith('');
|
1005
1064
|
});
|
1006
1065
|
test('add option shows when "hasAddOption" is provided', function () {
|
1007
|
-
(0, _testWrapper.render)((0,
|
1066
|
+
(0, _testWrapper.render)((0, _react3.jsx)(ComboBoxWithAddOption, null));
|
1008
1067
|
|
1009
1068
|
var input = _testWrapper.screen.queryByRole('combobox');
|
1010
1069
|
|
@@ -1025,7 +1084,7 @@ test('add option shows when "hasAddOption" is provided', function () {
|
|
1025
1084
|
expect(option).toHaveTextContent("ADD: ".concat(inputValue));
|
1026
1085
|
});
|
1027
1086
|
test('if "hasAddOption" is provided, then custom value is added to listbox on blur', function () {
|
1028
|
-
(0, _testWrapper.render)((0,
|
1087
|
+
(0, _testWrapper.render)((0, _react3.jsx)(ComboBoxWithAddOption, null));
|
1029
1088
|
|
1030
1089
|
var input = _testWrapper.screen.queryByRole('combobox');
|
1031
1090
|
|
@@ -1049,26 +1108,26 @@ test('if "hasAddOption" is provided, then custom value is added to listbox on bl
|
|
1049
1108
|
|
1050
1109
|
expect(options[options.length - 1]).toHaveTextContent(inputValue);
|
1051
1110
|
});
|
1052
|
-
test('should have no accessibility violations', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
1111
|
+
test('should have no accessibility violations', /*#__PURE__*/(0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
|
1053
1112
|
var _getComponent6, container, results;
|
1054
1113
|
|
1055
|
-
return _regenerator["default"].wrap(function
|
1114
|
+
return _regenerator["default"].wrap(function _callee5$(_context6) {
|
1056
1115
|
while (1) {
|
1057
|
-
switch (
|
1116
|
+
switch (_context6.prev = _context6.next) {
|
1058
1117
|
case 0:
|
1059
1118
|
jest.useRealTimers();
|
1060
1119
|
_getComponent6 = getComponent(), container = _getComponent6.container;
|
1061
|
-
|
1120
|
+
_context6.next = 4;
|
1062
1121
|
return (0, _jestAxe.axe)(container);
|
1063
1122
|
|
1064
1123
|
case 4:
|
1065
|
-
results =
|
1124
|
+
results = _context6.sent;
|
1066
1125
|
expect(results).toHaveNoViolations();
|
1067
1126
|
|
1068
1127
|
case 6:
|
1069
1128
|
case "end":
|
1070
|
-
return
|
1129
|
+
return _context6.stop();
|
1071
1130
|
}
|
1072
1131
|
}
|
1073
|
-
},
|
1132
|
+
}, _callee5);
|
1074
1133
|
})));
|
@@ -12,7 +12,7 @@ import _setTimeout from "@babel/runtime-corejs3/core-js-stable/set-timeout";
|
|
12
12
|
import _slicedToArray from "@babel/runtime-corejs3/helpers/esm/slicedToArray";
|
13
13
|
import _defineProperty from "@babel/runtime-corejs3/helpers/esm/defineProperty";
|
14
14
|
import _objectWithoutProperties from "@babel/runtime-corejs3/helpers/esm/objectWithoutProperties";
|
15
|
-
var _excluded = ["controlProps", "containerProps", "hasAutoFocus", "helperText", "isDisabled", "isReadOnly", "isOpen", "label", "labelProps", "loadingState", "status", "style", "inputRef", "inputProps", "triggerRef", "triggerProps", "menuTrigger", "onInputChange", "onLoadMore", "onOpenChange", "onSelectionChange", "wrapperProps"];
|
15
|
+
var _excluded = ["controlProps", "containerProps", "hasAutoFocus", "helperText", "isDisabled", "isReadOnly", "isOpen", "label", "labelProps", "loadingState", "status", "style", "inputWrapperRef", "inputRef", "inputProps", "triggerRef", "triggerProps", "menuTrigger", "onInputChange", "onLoadMore", "onOpenChange", "onSelectionChange", "wrapperProps"];
|
16
16
|
|
17
17
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
18
18
|
|
@@ -42,6 +42,7 @@ var ComboBoxInput = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
42
42
|
loadingState = props.loadingState,
|
43
43
|
status = props.status,
|
44
44
|
style = props.style,
|
45
|
+
inputWrapperRef = props.inputWrapperRef,
|
45
46
|
inputRef = props.inputRef,
|
46
47
|
inputProps = props.inputProps,
|
47
48
|
triggerRef = props.triggerRef,
|
@@ -147,6 +148,9 @@ var ComboBoxInput = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
147
148
|
ref: inputRef,
|
148
149
|
slots: {
|
149
150
|
inContainer: button
|
151
|
+
},
|
152
|
+
wrapperProps: {
|
153
|
+
ref: inputWrapperRef
|
150
154
|
}
|
151
155
|
}))));
|
152
156
|
});
|
@@ -162,6 +166,7 @@ ComboBoxInput.propTypes = {
|
|
162
166
|
label: PropTypes.node,
|
163
167
|
labelProps: PropTypes.shape({}),
|
164
168
|
loadingState: PropTypes.oneOf(_Object$values(loadingStates)),
|
169
|
+
inputWrapperRef: PropTypes.shape({}),
|
165
170
|
inputRef: PropTypes.shape({}),
|
166
171
|
triggerProps: PropTypes.shape({}),
|
167
172
|
triggerRef: PropTypes.shape({}),
|
@@ -113,6 +113,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
113
113
|
var buttonRef = useRef();
|
114
114
|
var listBoxRef = useRef();
|
115
115
|
var inputRef = useRef();
|
116
|
+
var inputWrapperRef = useRef();
|
116
117
|
usePropWarning(props, 'disabled', 'isDisabled');
|
117
118
|
/* istanbul ignore next */
|
118
119
|
|
@@ -181,7 +182,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
181
182
|
otherListBoxProps = _objectWithoutProperties(listBoxProps, _excluded);
|
182
183
|
|
183
184
|
var _useOverlayPosition = useOverlayPosition({
|
184
|
-
targetRef:
|
185
|
+
targetRef: inputWrapperRef,
|
185
186
|
overlayRef: popoverRef,
|
186
187
|
scrollRef: listBoxRef,
|
187
188
|
placement: "".concat(direction, " end"),
|
@@ -212,12 +213,12 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
212
213
|
|
213
214
|
var onResize = useCallback(function () {
|
214
215
|
/* istanbul ignore next */
|
215
|
-
if (
|
216
|
-
setMenuWidth(
|
216
|
+
if (inputWrapperRef.current) {
|
217
|
+
setMenuWidth(inputWrapperRef.current.offsetWidth);
|
217
218
|
}
|
218
|
-
}, [
|
219
|
+
}, [inputWrapperRef, setMenuWidth]);
|
219
220
|
useResizeObserver({
|
220
|
-
ref:
|
221
|
+
ref: inputWrapperRef,
|
221
222
|
onResize: onResize
|
222
223
|
});
|
223
224
|
useLayoutEffect(onResize, [onResize]);
|
@@ -254,6 +255,7 @@ var ComboBoxField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
254
255
|
isOpen: state.isOpen,
|
255
256
|
inputProps: inputProps,
|
256
257
|
labelProps: labelProps,
|
258
|
+
inputWrapperRef: inputWrapperRef,
|
257
259
|
inputRef: inputRef,
|
258
260
|
triggerProps: buttonProps,
|
259
261
|
triggerRef: buttonRef,
|
@@ -18,9 +18,10 @@ import _extends from "@babel/runtime-corejs3/helpers/esm/extends";
|
|
18
18
|
|
19
19
|
function ownKeys(object, enumerableOnly) { var keys = _Object$keys(object); if (_Object$getOwnPropertySymbols) { var symbols = _Object$getOwnPropertySymbols(object); enumerableOnly && (symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) { return _Object$getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
20
20
|
|
21
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var _context7, _context8; var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? _forEachInstanceProperty(_context7 = ownKeys(Object(source), !0)).call(_context7, function (key) { _defineProperty(target, key, source[key]); }) : _Object$getOwnPropertyDescriptors ? _Object$defineProperties(target, _Object$getOwnPropertyDescriptors(source)) : _forEachInstanceProperty(_context8 = ownKeys(Object(source))).call(_context8, function (key) { _Object$defineProperty(target, key, _Object$getOwnPropertyDescriptor(source, key)); }); } return target; }
|
22
22
|
|
23
23
|
import React, { useState, useMemo } from 'react';
|
24
|
+
import { fireEvent } from '@testing-library/react';
|
24
25
|
import { axe } from 'jest-axe';
|
25
26
|
import { useFilter } from '@react-aria/i18n';
|
26
27
|
import userEvent from '@testing-library/user-event';
|
@@ -509,6 +510,56 @@ test('should show in input "textValue" if provided', /*#__PURE__*/_asyncToGenera
|
|
509
510
|
}
|
510
511
|
}, _callee3);
|
511
512
|
})));
|
513
|
+
test('option list should be opened on scroll input value', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
|
514
|
+
var options, otherItems, input;
|
515
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context5) {
|
516
|
+
while (1) {
|
517
|
+
switch (_context5.prev = _context5.next) {
|
518
|
+
case 0:
|
519
|
+
otherItems = [{
|
520
|
+
name: 'Short item name one',
|
521
|
+
id: '1'
|
522
|
+
}, {
|
523
|
+
name: 'Short item name two',
|
524
|
+
id: '2'
|
525
|
+
}, {
|
526
|
+
name: 'Short item name three',
|
527
|
+
id: '3'
|
528
|
+
}, {
|
529
|
+
name: 'This is very very very long item name',
|
530
|
+
id: '4'
|
531
|
+
}];
|
532
|
+
getComponent({
|
533
|
+
defaultItems: otherItems
|
534
|
+
});
|
535
|
+
input = screen.queryByRole('combobox');
|
536
|
+
userEvent.type(input, '{arrowdown}');
|
537
|
+
options = screen.queryAllByRole('option');
|
538
|
+
expect(options).toHaveLength(otherItems.length);
|
539
|
+
userEvent.type(input, 'This is very very very long item name');
|
540
|
+
fireEvent.scroll(input, {
|
541
|
+
target: {
|
542
|
+
scrollX: 10
|
543
|
+
}
|
544
|
+
});
|
545
|
+
options = screen.queryAllByRole('option');
|
546
|
+
expect(options.length).toBe(1);
|
547
|
+
expect(options[0]).toHaveTextContent(otherItems[3].name);
|
548
|
+
fireEvent.scroll(window, {
|
549
|
+
target: {
|
550
|
+
scrollX: 10
|
551
|
+
}
|
552
|
+
});
|
553
|
+
options = screen.queryAllByRole('option');
|
554
|
+
expect(options.length).toBe(0);
|
555
|
+
|
556
|
+
case 14:
|
557
|
+
case "end":
|
558
|
+
return _context5.stop();
|
559
|
+
}
|
560
|
+
}
|
561
|
+
}, _callee4);
|
562
|
+
})));
|
512
563
|
describe('loadingState', function () {
|
513
564
|
it('combobox should not render a loader if menu is not open', function () {
|
514
565
|
var _getComponent = getComponent({
|
@@ -858,26 +909,26 @@ test('if "hasAddOption" is provided, then custom value is added to listbox on bl
|
|
858
909
|
var options = screen.queryAllByRole('option');
|
859
910
|
expect(options[options.length - 1]).toHaveTextContent(inputValue);
|
860
911
|
});
|
861
|
-
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
912
|
+
test('should have no accessibility violations', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
|
862
913
|
var _getComponent6, container, results;
|
863
914
|
|
864
|
-
return _regeneratorRuntime.wrap(function
|
915
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context6) {
|
865
916
|
while (1) {
|
866
|
-
switch (
|
917
|
+
switch (_context6.prev = _context6.next) {
|
867
918
|
case 0:
|
868
919
|
jest.useRealTimers();
|
869
920
|
_getComponent6 = getComponent(), container = _getComponent6.container;
|
870
|
-
|
921
|
+
_context6.next = 4;
|
871
922
|
return axe(container);
|
872
923
|
|
873
924
|
case 4:
|
874
|
-
results =
|
925
|
+
results = _context6.sent;
|
875
926
|
expect(results).toHaveNoViolations();
|
876
927
|
|
877
928
|
case 6:
|
878
929
|
case "end":
|
879
|
-
return
|
930
|
+
return _context6.stop();
|
880
931
|
}
|
881
932
|
}
|
882
|
-
},
|
933
|
+
}, _callee5);
|
883
934
|
})));
|