@pingux/astro 2.14.0-alpha.1 → 2.14.0-alpha.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.
- package/lib/cjs/components/MultivaluesField/MultivaluesField.js +9 -8
- package/lib/cjs/components/MultivaluesField/MultivaluesField.test.js +18 -0
- package/lib/components/MultivaluesField/MultivaluesField.js +9 -8
- package/lib/components/MultivaluesField/MultivaluesField.test.js +18 -0
- package/package.json +1 -1
@@ -102,6 +102,10 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
102
102
|
_useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
|
103
103
|
items = _useState8[0],
|
104
104
|
setItems = _useState8[1];
|
105
|
+
var _useState9 = (0, _react.useState)(''),
|
106
|
+
_useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
|
107
|
+
activeDescendant = _useState10[0],
|
108
|
+
setActiveDescendant = _useState10[1];
|
105
109
|
var toggleItems = function toggleItems(keys) {
|
106
110
|
setItems((0, _filter["default"])(initialItems).call(initialItems, function (item) {
|
107
111
|
var _context;
|
@@ -173,10 +177,10 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
173
177
|
}, [isOpen, selectionManager.selectedKeys, updatePosition]);
|
174
178
|
|
175
179
|
// Measure the width of the input to inform the width of the menu (below).
|
176
|
-
var
|
177
|
-
|
178
|
-
menuWidth =
|
179
|
-
setMenuWidth =
|
180
|
+
var _useState11 = (0, _react.useState)(null),
|
181
|
+
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
182
|
+
menuWidth = _useState12[0],
|
183
|
+
setMenuWidth = _useState12[1];
|
180
184
|
var onResize = (0, _react.useCallback)(function () {
|
181
185
|
/* istanbul ignore next */
|
182
186
|
if (inputWrapperRef.current) {
|
@@ -200,6 +204,7 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
200
204
|
}, []);
|
201
205
|
(0, _react.useEffect)(function () {
|
202
206
|
if (onOpenChange) onOpenChange(isOpen);
|
207
|
+
if (!isOpen) setActiveDescendant('');
|
203
208
|
}, [isOpen]);
|
204
209
|
var addNewBadgeFromInput = function addNewBadgeFromInput(inputValue) {
|
205
210
|
var _context3, _context4;
|
@@ -415,10 +420,6 @@ var MultivaluesField = /*#__PURE__*/(0, _react.forwardRef)(function (props, ref)
|
|
415
420
|
id: "emptyKeysState"
|
416
421
|
}, "Nothing Selected");
|
417
422
|
};
|
418
|
-
var _useState11 = (0, _react.useState)(null),
|
419
|
-
_useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
|
420
|
-
activeDescendant = _useState12[0],
|
421
|
-
setActiveDescendant = _useState12[1];
|
422
423
|
var inputProps = _objectSpread(_objectSpread({}, customInputProps), {}, {
|
423
424
|
controlProps: {
|
424
425
|
'aria-activedescendant': activeDescendant,
|
@@ -163,6 +163,24 @@ test('updates aria attributes on option focus', function () {
|
|
163
163
|
expect(input).toHaveAttribute('aria-expanded', 'true');
|
164
164
|
expect(input).toHaveAttribute('aria-controls', listbox.id);
|
165
165
|
});
|
166
|
+
test('updates aria attributes on popover closing after options were focused', function () {
|
167
|
+
getComponent();
|
168
|
+
var input = _testWrapper.screen.getByRole('combobox');
|
169
|
+
_userEvent["default"].tab();
|
170
|
+
expect(input).toHaveFocus();
|
171
|
+
_testWrapper.fireEvent.keyDown(input, {
|
172
|
+
key: 'ArrowDown'
|
173
|
+
});
|
174
|
+
var options = _testWrapper.screen.getAllByRole('option');
|
175
|
+
var listbox = _testWrapper.screen.getByRole('listbox');
|
176
|
+
expect(input).toHaveAttribute('aria-activedescendant', options[0].id);
|
177
|
+
expect(input).toHaveAttribute('aria-expanded', 'true');
|
178
|
+
expect(input).toHaveAttribute('aria-controls', listbox.id);
|
179
|
+
_userEvent["default"].click(document.body);
|
180
|
+
expect(input).toHaveAttribute('aria-activedescendant', '');
|
181
|
+
expect(input).toHaveAttribute('aria-expanded', 'false');
|
182
|
+
expect(input).not.toHaveAttribute('aria-controls');
|
183
|
+
});
|
166
184
|
test('clicking an option renders badge with option name', function () {
|
167
185
|
getComponent();
|
168
186
|
var input = _testWrapper.screen.getByRole('combobox');
|
@@ -90,6 +90,10 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
90
90
|
_useState8 = _slicedToArray(_useState7, 2),
|
91
91
|
items = _useState8[0],
|
92
92
|
setItems = _useState8[1];
|
93
|
+
var _useState9 = useState(''),
|
94
|
+
_useState10 = _slicedToArray(_useState9, 2),
|
95
|
+
activeDescendant = _useState10[0],
|
96
|
+
setActiveDescendant = _useState10[1];
|
93
97
|
var toggleItems = function toggleItems(keys) {
|
94
98
|
setItems(_filterInstanceProperty(initialItems).call(initialItems, function (item) {
|
95
99
|
var _context;
|
@@ -161,10 +165,10 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
161
165
|
}, [isOpen, selectionManager.selectedKeys, updatePosition]);
|
162
166
|
|
163
167
|
// Measure the width of the input to inform the width of the menu (below).
|
164
|
-
var
|
165
|
-
|
166
|
-
menuWidth =
|
167
|
-
setMenuWidth =
|
168
|
+
var _useState11 = useState(null),
|
169
|
+
_useState12 = _slicedToArray(_useState11, 2),
|
170
|
+
menuWidth = _useState12[0],
|
171
|
+
setMenuWidth = _useState12[1];
|
168
172
|
var onResize = useCallback(function () {
|
169
173
|
/* istanbul ignore next */
|
170
174
|
if (inputWrapperRef.current) {
|
@@ -188,6 +192,7 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
188
192
|
}, []);
|
189
193
|
useEffect(function () {
|
190
194
|
if (onOpenChange) onOpenChange(isOpen);
|
195
|
+
if (!isOpen) setActiveDescendant('');
|
191
196
|
}, [isOpen]);
|
192
197
|
var addNewBadgeFromInput = function addNewBadgeFromInput(inputValue) {
|
193
198
|
var _context3, _context4;
|
@@ -403,10 +408,6 @@ var MultivaluesField = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
403
408
|
id: "emptyKeysState"
|
404
409
|
}, "Nothing Selected");
|
405
410
|
};
|
406
|
-
var _useState11 = useState(null),
|
407
|
-
_useState12 = _slicedToArray(_useState11, 2),
|
408
|
-
activeDescendant = _useState12[0],
|
409
|
-
setActiveDescendant = _useState12[1];
|
410
411
|
var inputProps = _objectSpread(_objectSpread({}, customInputProps), {}, {
|
411
412
|
controlProps: {
|
412
413
|
'aria-activedescendant': activeDescendant,
|
@@ -160,6 +160,24 @@ test('updates aria attributes on option focus', function () {
|
|
160
160
|
expect(input).toHaveAttribute('aria-expanded', 'true');
|
161
161
|
expect(input).toHaveAttribute('aria-controls', listbox.id);
|
162
162
|
});
|
163
|
+
test('updates aria attributes on popover closing after options were focused', function () {
|
164
|
+
getComponent();
|
165
|
+
var input = screen.getByRole('combobox');
|
166
|
+
userEvent.tab();
|
167
|
+
expect(input).toHaveFocus();
|
168
|
+
fireEvent.keyDown(input, {
|
169
|
+
key: 'ArrowDown'
|
170
|
+
});
|
171
|
+
var options = screen.getAllByRole('option');
|
172
|
+
var listbox = screen.getByRole('listbox');
|
173
|
+
expect(input).toHaveAttribute('aria-activedescendant', options[0].id);
|
174
|
+
expect(input).toHaveAttribute('aria-expanded', 'true');
|
175
|
+
expect(input).toHaveAttribute('aria-controls', listbox.id);
|
176
|
+
userEvent.click(document.body);
|
177
|
+
expect(input).toHaveAttribute('aria-activedescendant', '');
|
178
|
+
expect(input).toHaveAttribute('aria-expanded', 'false');
|
179
|
+
expect(input).not.toHaveAttribute('aria-controls');
|
180
|
+
});
|
163
181
|
test('clicking an option renders badge with option name', function () {
|
164
182
|
getComponent();
|
165
183
|
var input = screen.getByRole('combobox');
|