@primer/react 0.0.0-20260413142532 → 0.0.0-20260413155135
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
|
@@ -241,17 +241,19 @@ function getDefaultPosition(anchorElement, overlayWidth) {
|
|
|
241
241
|
const rect = anchorElement.getBoundingClientRect();
|
|
242
242
|
const vw = window.innerWidth;
|
|
243
243
|
const viewportMargin = 8;
|
|
244
|
-
const
|
|
244
|
+
const spaceLeft = rect.left;
|
|
245
|
+
const spaceRight = vw - rect.right;
|
|
246
|
+
const horizontal = spaceLeft > spaceRight ? 'left' : 'right';
|
|
245
247
|
|
|
246
|
-
// If there's no explicit overlay width, or
|
|
248
|
+
// If there's no explicit overlay width, or either side has enough space
|
|
247
249
|
// to contain the overlay, let CSS position-try-fallbacks handle positioning
|
|
248
|
-
if (!overlayWidth ||
|
|
250
|
+
if (!overlayWidth || spaceLeft >= overlayWidth + viewportMargin || spaceRight >= overlayWidth + viewportMargin) {
|
|
249
251
|
return {
|
|
250
252
|
horizontal
|
|
251
253
|
};
|
|
252
254
|
}
|
|
253
255
|
const leftOffset = Math.max(0, overlayWidth - rect.right + viewportMargin);
|
|
254
|
-
const rightOffset = Math.max(0, rect.
|
|
256
|
+
const rightOffset = Math.max(0, rect.left + overlayWidth - vw + viewportMargin);
|
|
255
257
|
return {
|
|
256
258
|
horizontal,
|
|
257
259
|
leftOffset,
|
package/package.json
CHANGED