diff --git a/apps/docs-app/app/components/f/components/popover.gts b/apps/docs-app/app/components/f/components/popover.gts
index f8ed1a78..a0f40ac6 100644
--- a/apps/docs-app/app/components/f/components/popover.gts
+++ b/apps/docs-app/app/components/f/components/popover.gts
@@ -36,6 +36,9 @@ export default class extends Component {
@tracked
arrow: boolean = true;
+ @tracked
+ flip: boolean = false;
+
@tracked
isShown?: boolean;
@@ -62,6 +65,7 @@ export default class extends Component {
+
+
+
{
@tracked
_isShown = false;
+ @tracked
+ adjustedSide: Direction = 'bottom';
+
get hasArrow() {
return this.args.arrow ?? true;
}
@@ -120,6 +124,10 @@ export default class Popover extends Component {
get middleware() {
const middleware = [offset(this.offset)];
+ if (this.args.flip) {
+ middleware.push(flip());
+ }
+
if (this.hasArrow) {
middleware.push(arrow({ element: this.arrow! }));
}
@@ -201,6 +209,14 @@ export default class Popover extends Component {
return;
}
+ if (placement !== this.placement) {
+ this.adjustedSide = Object.keys(SIDE_TRANSLATION).find(
+ (side) => SIDE_TRANSLATION[side as Direction] === placement,
+ ) as Direction;
+ } else {
+ this.adjustedSide = this.side;
+ }
+
const { x: arrowX, y: arrowY } = middlewareData.arrow!;
const staticSide: string =
ARROW_SIDE[placement.split('-')[0] as Direction]!;
@@ -226,7 +242,7 @@ export default class Popover extends Component {
id={{this.id}}
class={{classes
(unless this.isShown "hidden")
- (concat "popover bs-popover-" this.side)
+ (concat "popover bs-popover-" this.adjustedSide)
}}
{{onInsert this.initPopover}}
{{! @glint-expect-error Modifier types are currently not correct }}
diff --git a/packages/ember-core/src/components/tooltip.gts b/packages/ember-core/src/components/tooltip.gts
index c928eb4f..9903151e 100644
--- a/packages/ember-core/src/components/tooltip.gts
+++ b/packages/ember-core/src/components/tooltip.gts
@@ -13,6 +13,7 @@ export interface TooltipSignature {
Args: {
alignment?: Alignment;
controlElement?: HTMLElement;
+ flip?: boolean;
isShown?: boolean;
offset?: string | number;
side?: Direction;
@@ -80,6 +81,7 @@ const Tooltip: TOC =