Skip to content

Commit b54ecd6

Browse files
committed
chore(test): resetting screenshot test for irrelevant issue
1 parent fdb24e4 commit b54ecd6

File tree

4 files changed

+48
-11
lines changed

4 files changed

+48
-11
lines changed
Loading

core/src/components/popover/animations/ios.enter.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ export const iosEnterAnimation = (baseEl: HTMLElement, opts?: any): Animation =>
7474
arrowTop,
7575
arrowLeft,
7676
addPopoverBottomClass,
77+
isFullyConstrained,
7778
} = calculateWindowAdjustment(
7879
side,
7980
results.top,
@@ -156,6 +157,13 @@ export const iosEnterAnimation = (baseEl: HTMLElement, opts?: any): Animation =>
156157

157158
if (bottomValue !== undefined) {
158159
contentEl.style.setProperty('bottom', `calc(${bottomValue})`);
160+
/**
161+
* When both top and bottom are set, we need to override the
162+
* height: var(--height) style to allow the top/bottom constraint
163+
* to determine the height. Setting height to 'auto' with both
164+
* top and bottom defined would cause bottom to be ignored.
165+
*/
166+
contentEl.style.setProperty('height', 'unset');
159167
}
160168

161169
contentEl.style.setProperty('top', `calc(${topValue} + var(--offset-y, 0))`);
@@ -164,7 +172,11 @@ export const iosEnterAnimation = (baseEl: HTMLElement, opts?: any): Animation =>
164172

165173
if (arrowEl !== null) {
166174
const didAdjustBounds = results.top !== top || results.left !== left;
167-
const showArrow = shouldShowArrow(side, didAdjustBounds, ev, trigger);
175+
/**
176+
* Hide the arrow when the popover is fully constrained to the viewport
177+
* because it cannot accurately point to the trigger in this case.
178+
*/
179+
const showArrow = shouldShowArrow(side, didAdjustBounds, ev, trigger) && !isFullyConstrained;
168180

169181
if (showArrow) {
170182
arrowEl.style.setProperty('top', `calc(${arrowTop}px + var(--offset-y, 0))`);

core/src/components/popover/animations/md.enter.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,13 @@ export const mdEnterAnimation = (baseEl: HTMLElement, opts?: any): Animation =>
134134
.beforeAddWrite(() => {
135135
if (bottomValue !== undefined) {
136136
contentEl.style.setProperty('bottom', `calc(${bottomValue})`);
137+
/**
138+
* When both top and bottom are set, we need to override the
139+
* height: var(--height) style to allow the top/bottom constraint
140+
* to determine the height. Setting height to 'auto' with both
141+
* top and bottom defined would cause bottom to be ignored.
142+
*/
143+
contentEl.style.setProperty('height', 'unset');
137144
}
138145
})
139146
.fromTo('transform', 'scale(0.8)', 'scale(1)');

core/src/components/popover/utils.ts

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ export interface PopoverStyles {
3737
arrowTop: number;
3838
arrowLeft: number;
3939
addPopoverBottomClass: boolean;
40+
/**
41+
* When true, the popover content was too tall to fit above or below
42+
* the trigger, so it was constrained to the full viewport height.
43+
* In this case, the arrow should be hidden as it cannot accurately
44+
* point to the trigger.
45+
*/
46+
isFullyConstrained: boolean;
4047
}
4148

4249
/**
@@ -835,6 +842,7 @@ export const calculateWindowAdjustment = (
835842
let checkSafeAreaBottom = false;
836843
let checkSafeAreaLeft = false;
837844
let checkSafeAreaRight = false;
845+
let isFullyConstrained = false;
838846
const triggerTop = triggerCoordinates
839847
? triggerCoordinates.top + triggerCoordinates.height
840848
: bodyHeight / 2 - contentHeight / 2;
@@ -845,20 +853,29 @@ export const calculateWindowAdjustment = (
845853
* Adjust popover so it does not
846854
* go off the left of the screen.
847855
*/
848-
if (left < bodyPadding + safeAreaMargin) {
856+
if (left < bodyPadding) {
849857
left = bodyPadding;
850-
checkSafeAreaLeft = true;
851858
originX = 'left';
852859
/**
853860
* Adjust popover so it does not
854861
* go off the right of the screen.
855862
*/
856-
} else if (contentWidth + bodyPadding + left + safeAreaMargin > bodyWidth) {
857-
checkSafeAreaRight = true;
863+
} else if (contentWidth + bodyPadding + left > bodyWidth) {
858864
left = bodyWidth - contentWidth - bodyPadding;
859865
originX = 'right';
860866
}
861867

868+
/**
869+
* After position adjustment, check if popover is near edges
870+
* and needs safe-area CSS variable adjustments.
871+
*/
872+
if (left <= safeAreaMargin) {
873+
checkSafeAreaLeft = true;
874+
}
875+
if (left + contentWidth >= bodyWidth - safeAreaMargin) {
876+
checkSafeAreaRight = true;
877+
}
878+
862879
/**
863880
* Adjust popover so it does not
864881
* go off the top of the screen.
@@ -894,16 +911,16 @@ export const calculateWindowAdjustment = (
894911

895912
/**
896913
* If not enough room for popover to appear
897-
* above trigger, then cut it off.
914+
* above trigger, constrain to full viewport.
915+
* Pin both top and bottom to maximize visible area
916+
* and let the content scroll within those bounds.
898917
*/
899918
} else {
919+
top = bodyPadding;
900920
bottom = bodyPadding;
901-
/**
902-
* When the popover is pinned to the bottom, account for safe area.
903-
* This ensures the popover doesn't overlap with home indicators
904-
* or navigation bars (e.g., Android API 36+ edge-to-edge).
905-
*/
921+
checkSafeAreaTop = true;
906922
checkSafeAreaBottom = true;
923+
isFullyConstrained = true;
907924
}
908925
}
909926

@@ -934,6 +951,7 @@ export const calculateWindowAdjustment = (
934951
arrowTop,
935952
arrowLeft,
936953
addPopoverBottomClass,
954+
isFullyConstrained,
937955
};
938956
};
939957

0 commit comments

Comments
 (0)