Auto-size hub order popup iframe so trade form shows without scrollbars.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-25 23:22:49 +08:00
parent 1767566951
commit 95d5469d12
7 changed files with 105 additions and 33 deletions
+28
View File
@@ -35,6 +35,22 @@
} catch (_) {}
}
function reportOrderPopupSize() {
if (!isOrderPopup()) return;
const root = document.querySelector(".embed-order-popup-shell") || document.body;
const h = Math.ceil(
Math.max(
root.scrollHeight,
root.offsetHeight,
document.documentElement.scrollHeight,
document.body.scrollHeight
)
);
try {
window.parent.postMessage({ type: "hub-order-popup-resize", height: h }, "*");
} catch (_) {}
}
function prefillOrderSymbolFromQuery() {
if (!isOrderPopup()) return;
let sym = "";
@@ -109,6 +125,7 @@
if (typeof global.refreshPriceSnapshotConditional === "function") {
global.refreshPriceSnapshotConditional();
}
reportOrderPopupSize();
}
function injectFragment(html) {
@@ -280,6 +297,17 @@
patchHardNavigations();
bindNav();
runPageInit(getTab());
reportOrderPopupSize();
if (isOrderPopup()) {
window.setTimeout(reportOrderPopupSize, 120);
window.setTimeout(reportOrderPopupSize, 450);
if (typeof ResizeObserver !== "undefined") {
const root = document.querySelector(".embed-order-popup-shell") || document.body;
try {
new ResizeObserver(() => reportOrderPopupSize()).observe(root);
} catch (_) {}
}
}
try {
window.parent.postMessage({ type: "instance-frame-ready" }, "*");
} catch (_) {}