Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/popover/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ import { describe, expect, it } from 'vitest';
import { calculateWindowAdjustment, getIndexOfItem, getNextItem, getPopoverPosition, getPrevItem } from './utils.js';

describe('popover utilities', () => {
it.each(['left', 'right', 'start', 'end'] as const)('preserves the vertical anchor alignment for side=%s', (side) => {
const position = calculateWindowAdjustment(side, 120, 100, 5, 440, 636, 200, 52, 8, 'right', 'center');
expect(position.top).toBe(120);
expect(calculateWindowAdjustment(side, -4, 100, 5, 440, 636, 200, 52, 8, 'right', 'center').top).toBe(5);
expect(calculateWindowAdjustment(side, 620, 100, 5, 440, 636, 200, 52, 8, 'right', 'center').top).toBe(579);
});

it('navigates only relative to ion-item elements', () => {
const items = [document.createElement('ion-item'), document.createElement('ion-item')] as HTMLIonItemElement[];

Expand Down
4 changes: 3 additions & 1 deletion src/popover/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,9 @@ export const calculateWindowAdjustment = (
const triggerTop = triggerCoordinates ? triggerCoordinates.top + triggerCoordinates.height : bodyHeight / 2 - contentHeight / 2;
const triggerHeight = triggerCoordinates ? triggerCoordinates.height : 0;
let left = coordLeft;
let top = !isReplace ? coordTop + POPOVER_IOS_BODY_MARGIN : coordTop - triggerHeight;
const horizontal = side === 'left' || side === 'right' || side === 'start' || side === 'end';
let top = !isReplace ? coordTop + (horizontal ? 0 : POPOVER_IOS_BODY_MARGIN) : coordTop - triggerHeight;
Comment on lines +619 to +620

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 画面上端付近の横向きポップオーバーが見切れる

上端付近で中央揃えの横向きポップオーバーを開くと、負の top が補正されず、内容が画面外に出ます。以前の 8px 補正で収まっていた位置でも発生します。

Learn more

横向き配置の座標は getPopoverPosition がトリガーと内容の寸法から算出します。中央揃えでは、トリガーが上端に近いと算出された top が負になることがあります。今回 8px の加算がなくなり、その負値が iosEnterAnimation の表示位置に使われます。

Example: 上端 7px、高さ 30px のトリガーに高さ 52px のポップオーバーを右側中央揃えで表示すると、算出座標は -4px です。従来の表示位置は 4px ですが、変更後は -4px になり上部が見切れます。

Recommended fix: 通常は算出座標を維持し、画面上端に出るときだけ表示位置を補正してください。補正時の矢印位置も確認してください。

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

if (horizontal && !isReplace) top = Math.max(bodyPadding, Math.min(top, bodyHeight - bodyPadding - contentHeight));
let bottom;
let originX = contentOriginX;
let originY = contentOriginY;
Expand Down
Loading