Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export function getVisibleArea(
const visibleArea = { ...initArea };

(scrollerList || []).forEach((ele) => {
if (ele instanceof HTMLBodyElement || ele instanceof HTMLHtmlElement) {
if (ele.tagName === 'BODY' || ele.tagName === 'HTML') {
Comment thread
PinkChampagne17 marked this conversation as resolved.
return;
}

Expand Down
21 changes: 21 additions & 0 deletions tests/flip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,27 @@ describe('Trigger.Align', () => {
window.getComputedStyle = oriGetComputedStyle;
});

it('skips iframe html and body elements', () => {
const initArea = {
left: 0,
right: 500,
top: 0,
bottom: 500,
};
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);

try {
const { documentElement, body } = iframe.contentDocument!;

expect(getVisibleArea(initArea, [documentElement, body])).toEqual(
initArea,
);
} finally {
iframe.remove();
}
});

// e.g. adjustY + shiftX may make popup out but push back in screen
// which should keep flip
/*
Expand Down