Fix options order panel vanishing after select.
Park the panel before strike-table rebuilds so soft chain refresh no longer destroys #opt-order-panel with innerHTML. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -79,13 +79,14 @@
|
||||
stopPendingOrdersPoll();
|
||||
const panel = orderPanel();
|
||||
const host = orderPanelHost();
|
||||
// 先把面板移回 host,再删行内 tr,避免 tbody.innerHTML 清空时把 #opt-order-panel 一起销毁
|
||||
if (panel && host) {
|
||||
if (panel.parentElement !== host) host.appendChild(panel);
|
||||
host.hidden = true;
|
||||
panel.style.display = "none";
|
||||
}
|
||||
const inline = document.querySelector(".opt-order-inline-row");
|
||||
if (inline) inline.remove();
|
||||
if (panel && host && panel.parentElement !== host) {
|
||||
host.appendChild(panel);
|
||||
host.hidden = true;
|
||||
}
|
||||
if (panel) panel.style.display = "none";
|
||||
document.querySelectorAll(".opt-strike-row").forEach(function (r) {
|
||||
r.classList.remove("opt-row-selected");
|
||||
});
|
||||
@@ -774,9 +775,9 @@
|
||||
const expMs = document.getElementById("opt-exp-select").value;
|
||||
const prevSelected = state.selectedInst;
|
||||
const cols = strikeTableColspan();
|
||||
parkOrderPanel();
|
||||
tbody.innerHTML = "";
|
||||
if (!expMs || !state.chain) {
|
||||
parkOrderPanel();
|
||||
tbody.innerHTML = '<tr><td colspan="' + cols + '" class="muted">请选择到期日</td></tr>';
|
||||
state.selectedInst = null;
|
||||
return;
|
||||
@@ -785,21 +786,17 @@
|
||||
return String(e.exp_time) === String(expMs);
|
||||
});
|
||||
if (!exp) {
|
||||
parkOrderPanel();
|
||||
state.selectedInst = null;
|
||||
return;
|
||||
}
|
||||
const list = filterChainContracts(exp.contracts);
|
||||
if (!list.length) {
|
||||
parkOrderPanel();
|
||||
const label = moneyFilterLabel();
|
||||
const suffix = label ? label : optTypeLabel(state.optType);
|
||||
tbody.innerHTML = '<tr><td colspan="' + cols + '" class="muted">该到期日暂无' + suffix + "合约</td></tr>";
|
||||
state.selectedInst = null;
|
||||
return;
|
||||
}
|
||||
const stillVisible = !!prevSelected && list.some(function (c) { return c.inst_id === prevSelected; });
|
||||
if (!stillVisible) parkOrderPanel();
|
||||
let matchedSelected = false;
|
||||
list.forEach(function (c) {
|
||||
const tr = document.createElement("tr");
|
||||
@@ -829,9 +826,9 @@
|
||||
const prevSelected = state.selectedInst;
|
||||
const cols = strikeTableColspan();
|
||||
const indexPx = state.chain && state.chain.index_px;
|
||||
parkOrderPanel();
|
||||
tbody.innerHTML = "";
|
||||
if (!expMs || !state.chain) {
|
||||
parkOrderPanel();
|
||||
tbody.innerHTML = '<tr><td colspan="' + cols + '" class="muted">请选择到期日</td></tr>';
|
||||
state.selectedInst = null;
|
||||
return;
|
||||
@@ -840,14 +837,12 @@
|
||||
return String(e.exp_time) === String(expMs);
|
||||
});
|
||||
if (!exp) {
|
||||
parkOrderPanel();
|
||||
state.selectedInst = null;
|
||||
return;
|
||||
}
|
||||
let rows = filterStraddleRows(buildStraddleRows(exp.contracts), indexPx);
|
||||
rows = sliceAtmWindow(rows, indexPx);
|
||||
if (!rows.length) {
|
||||
parkOrderPanel();
|
||||
const label = moneyFilterLabel();
|
||||
const suffix = label ? label + "区" : "匹配";
|
||||
tbody.innerHTML = '<tr><td colspan="' + cols + '" class="muted">该到期日暂无' + suffix + "行权价</td></tr>";
|
||||
@@ -855,13 +850,6 @@
|
||||
return;
|
||||
}
|
||||
const atmStrike = findAtmStrike(rows, indexPx);
|
||||
const visibleInsts = [];
|
||||
rows.forEach(function (row) {
|
||||
if (row.call && row.call.inst_id) visibleInsts.push(row.call.inst_id);
|
||||
if (row.put && row.put.inst_id) visibleInsts.push(row.put.inst_id);
|
||||
});
|
||||
const stillVisible = !!prevSelected && visibleInsts.indexOf(prevSelected) >= 0;
|
||||
if (!stillVisible) parkOrderPanel();
|
||||
let matchedSelected = false;
|
||||
rows.forEach(function (row) {
|
||||
const call = row.call;
|
||||
@@ -1003,7 +991,6 @@
|
||||
alert(lastMsg || "加载到期日失败,请点「刷新链」重试");
|
||||
return;
|
||||
}
|
||||
const keepSel = soft && state.selectedInst;
|
||||
const keepExp = soft ? (document.getElementById("opt-exp-select") || {}).value : "";
|
||||
state.chain = d;
|
||||
panelCache.chain = d;
|
||||
@@ -1025,8 +1012,8 @@
|
||||
sel.value = keepExp;
|
||||
}
|
||||
}
|
||||
// soft 时保留 selectedInst;renderStrikes 会先 park 再按 prevSelected 静默重挂下单面板
|
||||
renderStrikes();
|
||||
if (soft && keepSel) state.selectedInst = keepSel;
|
||||
} catch (e) {
|
||||
if (seq !== chainLoadSeq || soft) return;
|
||||
setExpirySelectStatus("选择到期日");
|
||||
|
||||
Reference in New Issue
Block a user