Auto-size hub order popup iframe so trade form shows without scrollbars.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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 (_) {}
|
||||
|
||||
Reference in New Issue
Block a user