@primer/react 0.0.0-20260623213401 → 0.0.0-20260624174518
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @primer/react
|
|
2
2
|
|
|
3
|
-
## 0.0.0-
|
|
3
|
+
## 0.0.0-20260624174518
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
- [#8021](https://github.com/primer/react/pull/8021) [`6131a94`](https://github.com/primer/react/commit/6131a9424b5bd5bb98b7ae05771d8187fe2f58cd) Thanks [@mattcosta7](https://github.com/mattcosta7)! - TextInput: Improve typing performance by deriving the character counter in render instead of in effects, removing extra re-renders on each keystroke.
|
|
34
34
|
|
|
35
|
-
- [#8037](https://github.com/primer/react/pull/8037) [`7749e0d`](https://github.com/primer/react/commit/7749e0da6eaf7baec66a106846e8159880cd434f) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Fix `UnderlineNav` not re-rendering when child tabs are added
|
|
35
|
+
- [#8037](https://github.com/primer/react/pull/8037) [`7749e0d`](https://github.com/primer/react/commit/7749e0da6eaf7baec66a106846e8159880cd434f) Thanks [@liuliu-dev](https://github.com/liuliu-dev)! - Fix `UnderlineNav` not re-rendering when child tabs are added or removed.
|
|
36
36
|
|
|
37
37
|
## 38.29.0
|
|
38
38
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAqBtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAsGhC,eAAO,MAAM,YAAY,
|
|
1
|
+
{"version":3,"file":"UnderlineNav.d.ts","sourceRoot":"","sources":["../../src/UnderlineNav/UnderlineNav.tsx"],"names":[],"mappings":"AACA,OAAO,KAAkD,MAAM,OAAO,CAAA;AAqBtE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;IACzB,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,YAAY,CAAC,CAAA;IACjD,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,eAAe,CAAC,EAAE,OAAO,CAAA;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;CAC5B,CAAA;AAGD,eAAO,MAAM,cAAc,KAAK,CAAA;AAsGhC,eAAO,MAAM,YAAY,mFAsTxB,CAAA"}
|
|
@@ -142,46 +142,27 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
142
142
|
menuItems: []
|
|
143
143
|
});
|
|
144
144
|
|
|
145
|
-
//
|
|
146
|
-
//
|
|
145
|
+
// Track the set of children so the overflow effect re-runs whenever children are
|
|
146
|
+
// added or removed (not just when the nav element resizes). Keys are sorted so that
|
|
147
|
+
// simply reordering existing children doesn't trigger an unnecessary recalculation.
|
|
147
148
|
const childrenSignature = validChildren.map(child => {
|
|
148
149
|
var _child$key;
|
|
149
150
|
return String((_child$key = child.key) !== null && _child$key !== void 0 ? _child$key : '');
|
|
150
|
-
}).join('|');
|
|
151
|
-
|
|
152
|
-
// `childrenChanged` only tracks membership (set of keys), not order. This is intentional
|
|
153
|
-
// because `swapMenuItemWithListItem` legitimately reorders `responsiveProps.items` (to keep
|
|
154
|
-
// the selected item visible), and we don't want that to be treated as a stale-children
|
|
155
|
-
// situation. We only need to fall back to rendering `validChildren` directly when a child
|
|
156
|
-
// was actually added or removed (so a new item isn't missed and a removed item isn't kept).
|
|
157
|
-
const responsiveKeys = new Set();
|
|
158
|
-
for (const item of responsiveProps.items) {
|
|
159
|
-
var _item$key;
|
|
160
|
-
responsiveKeys.add(String((_item$key = item.key) !== null && _item$key !== void 0 ? _item$key : ''));
|
|
161
|
-
}
|
|
162
|
-
for (const item of responsiveProps.menuItems) {
|
|
163
|
-
var _item$key2;
|
|
164
|
-
responsiveKeys.add(String((_item$key2 = item.key) !== null && _item$key2 !== void 0 ? _item$key2 : ''));
|
|
165
|
-
}
|
|
166
|
-
const validKeys = validChildren.map(child => {
|
|
167
|
-
var _child$key2;
|
|
168
|
-
return String((_child$key2 = child.key) !== null && _child$key2 !== void 0 ? _child$key2 : '');
|
|
169
|
-
});
|
|
170
|
-
const childrenChanged = validKeys.length !== responsiveKeys.size || validKeys.some(key => !responsiveKeys.has(key));
|
|
151
|
+
}).sort().join('|');
|
|
171
152
|
|
|
172
153
|
// Make sure to have the fresh props data for list items when children are changed (keeping aria-current up-to-date)
|
|
173
|
-
const listItems =
|
|
154
|
+
const listItems = responsiveProps.items.map(item => {
|
|
174
155
|
var _validChildren$find;
|
|
175
156
|
return (_validChildren$find = validChildren.find(child => child.key === item.key)) !== null && _validChildren$find !== void 0 ? _validChildren$find : item;
|
|
176
157
|
});
|
|
177
158
|
|
|
178
159
|
// Make sure to have the fresh props data for menu items when children are changed (keeping aria-current up-to-date)
|
|
179
|
-
const menuItems =
|
|
160
|
+
const menuItems = responsiveProps.menuItems.map(menuItem => {
|
|
180
161
|
var _validChildren$find2;
|
|
181
162
|
return (_validChildren$find2 = validChildren.find(child => child.key === menuItem.key)) !== null && _validChildren$find2 !== void 0 ? _validChildren$find2 : menuItem;
|
|
182
163
|
});
|
|
183
164
|
// This is the case where the viewport is too narrow to show any list item with the more menu. In this case, we only show the dropdown
|
|
184
|
-
const onlyMenuVisible =
|
|
165
|
+
const onlyMenuVisible = responsiveProps.items.length === 0;
|
|
185
166
|
useDevOnlyEffect(() => {
|
|
186
167
|
// Address illegal state where there are multiple items that have `aria-current='page'` attribute
|
|
187
168
|
const activeElements = validChildren.filter(child => {
|
|
@@ -275,11 +256,6 @@ const UnderlineNav = /*#__PURE__*/forwardRef(({
|
|
|
275
256
|
containerRef,
|
|
276
257
|
ignoreClickRefs: [moreMenuBtnRef]
|
|
277
258
|
});
|
|
278
|
-
|
|
279
|
-
// The resize observer fires when the nav element resizes, and re-observes (firing the
|
|
280
|
-
// callback again with current size) whenever its deps change. Passing `childrenSignature`
|
|
281
|
-
// ensures the overflow calculation re-runs when child tabs are added, removed, or
|
|
282
|
-
// reordered. See https://github.com/github/primer/issues/6389.
|
|
283
259
|
useResizeObserver(resizeObserverEntries => {
|
|
284
260
|
var _moreMenuRef$current$, _moreMenuRef$current;
|
|
285
261
|
const navWidth = resizeObserverEntries[0].contentRect.width;
|
package/package.json
CHANGED