@primer/react 0.0.0-20260501191321 → 0.0.0-20260501201044
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
|
@@ -271,11 +271,21 @@ function getDefaultPosition(anchorElement, overlayElement, fallbackWidth) {
|
|
|
271
271
|
const spaceRight = vw - anchorRect.right;
|
|
272
272
|
const horizontal = spaceLeft > spaceRight ? 'left' : 'right';
|
|
273
273
|
|
|
274
|
-
// Suggest
|
|
275
|
-
//
|
|
274
|
+
// Suggest a flip when the overlay is currently overflowing both axes:
|
|
275
|
+
// prefer the side of the anchor with enough room, otherwise fall back to
|
|
276
|
+
// outside-bottom and let the offsets keep it inside the viewport.
|
|
276
277
|
const overflowsX = overlayRect.right > vw || overlayRect.left < 0;
|
|
277
278
|
const overflowsY = overlayRect.bottom > vh || overlayRect.top < 0;
|
|
278
|
-
|
|
279
|
+
let suggestedSide;
|
|
280
|
+
if (overflowsX && overflowsY) {
|
|
281
|
+
if (spaceLeft >= overlayWidth + margin) {
|
|
282
|
+
suggestedSide = 'outside-left';
|
|
283
|
+
} else if (spaceRight >= overlayWidth + margin) {
|
|
284
|
+
suggestedSide = 'outside-right';
|
|
285
|
+
} else {
|
|
286
|
+
suggestedSide = 'outside-bottom';
|
|
287
|
+
}
|
|
288
|
+
}
|
|
279
289
|
|
|
280
290
|
// If the viewport is too narrow to fit the overlay on either side, calculate offsets to prevent overflow.
|
|
281
291
|
let leftOffset;
|
package/package.json
CHANGED