@primer/react 38.37.1-rc.c2576f920 → 38.37.1-rc.f1c7ced7b
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
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
### Patch Changes
|
|
6
6
|
|
|
7
|
+
- [#8343](https://github.com/primer/react/pull/8343) [`7034e1f`](https://github.com/primer/react/commit/7034e1fbb754883b29a05fdf75eea8704359e7bb) Thanks [@llastflowers](https://github.com/llastflowers)! - Don't focus Autocomplete menu items while menu is closed: fix SR announcement bug and menu item skipping bug
|
|
8
|
+
|
|
7
9
|
- [#8339](https://github.com/primer/react/pull/8339) [`1f5b99e`](https://github.com/primer/react/commit/1f5b99edc63e3989eb470d258c4d7b8703540f6b) Thanks [@ShiyunXu](https://github.com/ShiyunXu)! - Pin `box-sizing` with `!important` on the underline tabbed interface wrapper in wrap mode so external overrides can no longer offset its height budget and incorrectly trigger the overflow "more" menu
|
|
8
10
|
|
|
9
11
|
## 38.37.0
|
|
@@ -6,7 +6,7 @@ import { jsx } from "react/jsx-runtime";
|
|
|
6
6
|
import React, { useCallback, useContext, useEffect, useState } from "react";
|
|
7
7
|
//#region src/Autocomplete/AutocompleteInput.tsx
|
|
8
8
|
const ARROW_KEYS_NAV = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown"]);
|
|
9
|
-
const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = TextInput_default, onFocus, onBlur, onChange, onKeyDown, onKeyUp, onKeyPress, value, openOnFocus = false, ...props }, forwardedRef) => {
|
|
9
|
+
const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = TextInput_default, onFocus, onBlur, onChange, onKeyDown, onKeyDownCapture, onKeyUp, onKeyPress, value, openOnFocus = false, ...props }, forwardedRef) => {
|
|
10
10
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
11
11
|
const inputContext = useContext(AutocompleteInputContext);
|
|
12
12
|
if (autocompleteContext === null || inputContext === null) throw new Error("AutocompleteContext returned null values");
|
|
@@ -60,6 +60,10 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
60
60
|
showMenu,
|
|
61
61
|
setShowMenu
|
|
62
62
|
]);
|
|
63
|
+
const handleInputKeyDownCapture = (event) => {
|
|
64
|
+
onKeyDownCapture === null || onKeyDownCapture === void 0 || onKeyDownCapture(event);
|
|
65
|
+
if (!showMenu && ARROW_KEYS_NAV.has(event.key) && !event.altKey) event.preventDefault();
|
|
66
|
+
};
|
|
63
67
|
const handleInputKeyUp = useCallback((event) => {
|
|
64
68
|
onKeyUp === null || onKeyUp === void 0 || onKeyUp(event);
|
|
65
69
|
if (event.key === "Backspace") setHighlightRemainingText(true);
|
|
@@ -98,6 +102,7 @@ const AutocompleteInput = /*#__PURE__*/ React.forwardRef(({ as: Component = Text
|
|
|
98
102
|
onBlur: handleInputBlur,
|
|
99
103
|
onChange: handleInputChange,
|
|
100
104
|
onKeyDown: handleInputKeyDown,
|
|
105
|
+
onKeyDownCapture: handleInputKeyDownCapture,
|
|
101
106
|
onKeyPress: onInputKeyPress,
|
|
102
107
|
onKeyUp: handleInputKeyUp,
|
|
103
108
|
ref: mergedRef,
|
|
@@ -43,7 +43,7 @@ const debounceAnnouncement = debounce((announcement) => {
|
|
|
43
43
|
announce(announcement);
|
|
44
44
|
}, 250);
|
|
45
45
|
function AutocompleteMenu(props) {
|
|
46
|
-
const $ = c(
|
|
46
|
+
const $ = c(80);
|
|
47
47
|
const autocompleteContext = useContext(AutocompleteContext);
|
|
48
48
|
const deferredInputContext = useContext(AutocompleteDeferredInputContext);
|
|
49
49
|
if (autocompleteContext === null || deferredInputContext === null) throw new Error("AutocompleteContext returned null values");
|
|
@@ -188,9 +188,10 @@ function AutocompleteMenu(props) {
|
|
|
188
188
|
t11 = $[38];
|
|
189
189
|
}
|
|
190
190
|
React.useEffect(t10, t11);
|
|
191
|
-
|
|
191
|
+
const t12 = !showMenu;
|
|
192
|
+
let t13;
|
|
192
193
|
if ($[39] !== activeDescendantRef || $[40] !== customScrollContainerRef || $[41] !== scrollContainerRef || $[42] !== setIsMenuDirectlyActivated) {
|
|
193
|
-
|
|
194
|
+
t13 = (current, _previous, directlyActivated) => {
|
|
194
195
|
activeDescendantRef.current = current || null;
|
|
195
196
|
if (current) {
|
|
196
197
|
const selectedItem = allItemsToRenderRef.current.find((item_1) => {
|
|
@@ -207,102 +208,105 @@ function AutocompleteMenu(props) {
|
|
|
207
208
|
$[40] = customScrollContainerRef;
|
|
208
209
|
$[41] = scrollContainerRef;
|
|
209
210
|
$[42] = setIsMenuDirectlyActivated;
|
|
210
|
-
$[43] =
|
|
211
|
-
} else
|
|
212
|
-
let
|
|
213
|
-
if ($[44] !== inputRef || $[45] !== t12) {
|
|
214
|
-
|
|
211
|
+
$[43] = t13;
|
|
212
|
+
} else t13 = $[43];
|
|
213
|
+
let t14;
|
|
214
|
+
if ($[44] !== inputRef || $[45] !== t12 || $[46] !== t13) {
|
|
215
|
+
t14 = {
|
|
215
216
|
containerRef: listContainerRef,
|
|
217
|
+
disabled: t12,
|
|
216
218
|
focusOutBehavior: "wrap",
|
|
217
219
|
focusableElementFilter: _temp4,
|
|
218
220
|
activeDescendantFocus: inputRef,
|
|
219
|
-
onActiveDescendantChanged:
|
|
221
|
+
onActiveDescendantChanged: t13
|
|
220
222
|
};
|
|
221
223
|
$[44] = inputRef;
|
|
222
224
|
$[45] = t12;
|
|
223
225
|
$[46] = t13;
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
if ($[47] !== loading) {
|
|
227
|
-
t14 = [loading];
|
|
228
|
-
$[47] = loading;
|
|
229
|
-
$[48] = t14;
|
|
230
|
-
} else t14 = $[48];
|
|
231
|
-
useFocusZone(t13, t14);
|
|
226
|
+
$[47] = t14;
|
|
227
|
+
} else t14 = $[47];
|
|
232
228
|
let t15;
|
|
229
|
+
if ($[48] !== loading) {
|
|
230
|
+
t15 = [loading];
|
|
231
|
+
$[48] = loading;
|
|
232
|
+
$[49] = t15;
|
|
233
|
+
} else t15 = $[49];
|
|
234
|
+
useFocusZone(t14, t15);
|
|
233
235
|
let t16;
|
|
234
|
-
|
|
235
|
-
|
|
236
|
+
let t17;
|
|
237
|
+
if ($[50] !== deferredInputValue || $[51] !== highlightedItem || $[52] !== selectedItemIds || $[53] !== setAutocompleteSuggestion) {
|
|
238
|
+
t16 = () => {
|
|
236
239
|
var _highlightedItem$text;
|
|
237
240
|
if (highlightedItem !== null && highlightedItem !== void 0 && (_highlightedItem$text = highlightedItem.text) !== null && _highlightedItem$text !== void 0 && _highlightedItem$text.startsWith(deferredInputValue) && !selectedItemIds.includes(highlightedItem.id)) setAutocompleteSuggestion(highlightedItem.text);
|
|
238
241
|
else setAutocompleteSuggestion("");
|
|
239
242
|
};
|
|
240
|
-
|
|
243
|
+
t17 = [
|
|
241
244
|
highlightedItem,
|
|
242
245
|
deferredInputValue,
|
|
243
246
|
selectedItemIds,
|
|
244
247
|
setAutocompleteSuggestion
|
|
245
248
|
];
|
|
246
|
-
$[
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
$[53] = t15;
|
|
249
|
+
$[50] = deferredInputValue;
|
|
250
|
+
$[51] = highlightedItem;
|
|
251
|
+
$[52] = selectedItemIds;
|
|
252
|
+
$[53] = setAutocompleteSuggestion;
|
|
251
253
|
$[54] = t16;
|
|
254
|
+
$[55] = t17;
|
|
252
255
|
} else {
|
|
253
|
-
t15 = $[53];
|
|
254
256
|
t16 = $[54];
|
|
257
|
+
t17 = $[55];
|
|
255
258
|
}
|
|
256
|
-
useEffect(
|
|
257
|
-
let t17;
|
|
259
|
+
useEffect(t16, t17);
|
|
258
260
|
let t18;
|
|
259
|
-
|
|
260
|
-
|
|
261
|
+
let t19;
|
|
262
|
+
if ($[56] !== onOpenChange || $[57] !== selectedItemIds || $[58] !== showMenu || $[59] !== sortOnCloseFn || $[60] !== sortedItemIds) {
|
|
263
|
+
t18 = () => {
|
|
261
264
|
const itemIdSortResult = [...sortedItemIds].sort(sortOnCloseFn ? sortOnCloseFn : getDefaultSortFn((itemId_0) => isItemSelected(itemId_0, selectedItemIds)));
|
|
262
265
|
const sortResultMatchesState = itemIdSortResult.length === sortedItemIds.length && itemIdSortResult.every((element_0, index) => element_0 === sortedItemIds[index]);
|
|
263
266
|
if (showMenu === false && !sortResultMatchesState) setSortedItemIds(itemIdSortResult);
|
|
264
267
|
onOpenChange && onOpenChange(Boolean(showMenu));
|
|
265
268
|
};
|
|
266
|
-
|
|
269
|
+
t19 = [
|
|
267
270
|
showMenu,
|
|
268
271
|
onOpenChange,
|
|
269
272
|
selectedItemIds,
|
|
270
273
|
sortOnCloseFn,
|
|
271
274
|
sortedItemIds
|
|
272
275
|
];
|
|
273
|
-
$[
|
|
274
|
-
$[
|
|
275
|
-
$[
|
|
276
|
-
$[
|
|
277
|
-
$[
|
|
278
|
-
$[60] = t17;
|
|
276
|
+
$[56] = onOpenChange;
|
|
277
|
+
$[57] = selectedItemIds;
|
|
278
|
+
$[58] = showMenu;
|
|
279
|
+
$[59] = sortOnCloseFn;
|
|
280
|
+
$[60] = sortedItemIds;
|
|
279
281
|
$[61] = t18;
|
|
282
|
+
$[62] = t19;
|
|
280
283
|
} else {
|
|
281
|
-
t17 = $[60];
|
|
282
284
|
t18 = $[61];
|
|
285
|
+
t19 = $[62];
|
|
283
286
|
}
|
|
284
|
-
useEffect(
|
|
285
|
-
let
|
|
286
|
-
if ($[
|
|
287
|
-
|
|
287
|
+
useEffect(t18, t19);
|
|
288
|
+
let t20;
|
|
289
|
+
if ($[63] !== selectedItemIds.length || $[64] !== setSelectedItemLength) {
|
|
290
|
+
t20 = () => {
|
|
288
291
|
if (selectedItemIds.length) setSelectedItemLength(selectedItemIds.length);
|
|
289
292
|
};
|
|
290
|
-
$[
|
|
291
|
-
$[
|
|
292
|
-
$[
|
|
293
|
-
} else
|
|
294
|
-
let t20;
|
|
295
|
-
if ($[65] !== selectedItemIds || $[66] !== setSelectedItemLength) {
|
|
296
|
-
t20 = [selectedItemIds, setSelectedItemLength];
|
|
297
|
-
$[65] = selectedItemIds;
|
|
298
|
-
$[66] = setSelectedItemLength;
|
|
299
|
-
$[67] = t20;
|
|
300
|
-
} else t20 = $[67];
|
|
301
|
-
useEffect(t19, t20);
|
|
302
|
-
if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
293
|
+
$[63] = selectedItemIds.length;
|
|
294
|
+
$[64] = setSelectedItemLength;
|
|
295
|
+
$[65] = t20;
|
|
296
|
+
} else t20 = $[65];
|
|
303
297
|
let t21;
|
|
304
|
-
if ($[
|
|
305
|
-
t21 =
|
|
298
|
+
if ($[66] !== selectedItemIds || $[67] !== setSelectedItemLength) {
|
|
299
|
+
t21 = [selectedItemIds, setSelectedItemLength];
|
|
300
|
+
$[66] = selectedItemIds;
|
|
301
|
+
$[67] = setSelectedItemLength;
|
|
302
|
+
$[68] = t21;
|
|
303
|
+
} else t21 = $[68];
|
|
304
|
+
useEffect(t20, t21);
|
|
305
|
+
if (selectionVariant === "single" && selectedItemIds.length > 1) throw new Error("Autocomplete: selectionVariant \"single\" cannot be used with multiple selected items");
|
|
306
|
+
const t22 = !showMenu;
|
|
307
|
+
let t23;
|
|
308
|
+
if ($[69] !== allItemsToRender || $[70] !== ariaLabelledBy || $[71] !== emptyStateText || $[72] !== id || $[73] !== loading || $[74] !== selectionVariant) {
|
|
309
|
+
t23 = loading ? /*#__PURE__*/ jsx("div", {
|
|
306
310
|
className: AutocompleteMenu_module_css_default.SpinnerWrapper,
|
|
307
311
|
children: /*#__PURE__*/ jsx(Spinner, {})
|
|
308
312
|
}) : /*#__PURE__*/ jsx("div", {
|
|
@@ -319,25 +323,27 @@ function AutocompleteMenu(props) {
|
|
|
319
323
|
children: emptyStateText
|
|
320
324
|
}) : null
|
|
321
325
|
});
|
|
322
|
-
$[
|
|
323
|
-
$[
|
|
324
|
-
$[
|
|
325
|
-
$[
|
|
326
|
-
$[
|
|
327
|
-
$[
|
|
328
|
-
$[
|
|
329
|
-
} else
|
|
330
|
-
let
|
|
331
|
-
if ($[
|
|
332
|
-
|
|
326
|
+
$[69] = allItemsToRender;
|
|
327
|
+
$[70] = ariaLabelledBy;
|
|
328
|
+
$[71] = emptyStateText;
|
|
329
|
+
$[72] = id;
|
|
330
|
+
$[73] = loading;
|
|
331
|
+
$[74] = selectionVariant;
|
|
332
|
+
$[75] = t23;
|
|
333
|
+
} else t23 = $[75];
|
|
334
|
+
let t24;
|
|
335
|
+
if ($[76] !== showMenu || $[77] !== t22 || $[78] !== t23) {
|
|
336
|
+
t24 = /*#__PURE__*/ jsx(VisuallyHidden, {
|
|
333
337
|
isVisible: showMenu,
|
|
334
|
-
|
|
338
|
+
hidden: t22,
|
|
339
|
+
children: t23
|
|
335
340
|
});
|
|
336
|
-
$[
|
|
337
|
-
$[76] = t21;
|
|
341
|
+
$[76] = showMenu;
|
|
338
342
|
$[77] = t22;
|
|
339
|
-
|
|
340
|
-
|
|
343
|
+
$[78] = t23;
|
|
344
|
+
$[79] = t24;
|
|
345
|
+
} else t24 = $[79];
|
|
346
|
+
return t24;
|
|
341
347
|
}
|
|
342
348
|
function _temp5(item_2) {
|
|
343
349
|
const { id: id_0, onAction, children, text, leadingVisual: LeadingVisual, trailingVisual: TrailingVisual, key, role, ...itemProps } = item_2;
|
package/package.json
CHANGED