Skip to content

Commit 48de3b6

Browse files
committed
BsPopover: improve display positioning
1 parent a6c95c1 commit 48de3b6

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/components/Menu/dropdownMenu.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
}
1616
}
1717

18-
~ .#{$prefix}btn-icon {
19-
margin-left: $padding-xs;
20-
}
18+
// ~ .#{$prefix}btn-icon {
19+
// margin-left: $padding-xs;
20+
// }
2121
}
2222

2323
.#{$prefix}popover-dropdown-menu {

src/components/Popover/mixins/popoverApi.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ function getPopoverLeftPosition(
6060
break;
6161
case 'top':
6262
case 'bottom':
63-
offsetLeft = activatorRect.left + activatorRect.width / 2 - width / 2;
63+
offsetLeft = activatorRect.left + (activatorRect.width / 2) - (width / 2);
6464
break;
6565
case 'bottom-left':
6666
case 'top-left':
@@ -71,6 +71,12 @@ function getPopoverLeftPosition(
7171
offsetLeft = activatorRect.left + activatorRect.width - width;
7272
break;
7373
}
74+
75+
if (['top', 'top-left', 'bottom', 'bottom-left'].includes(placement as string)) {
76+
if ((offsetLeft + width) >= (maxLeft + width)) {
77+
offsetLeft = maxLeft;
78+
}
79+
}
7480

7581
return Math.max(minLeft, offsetLeft);
7682
}

0 commit comments

Comments
 (0)