fix: never collapse warning container — always reserve space to prevent layout shift
All checks were successful
check / check (push) Successful in 10s
All checks were successful
check / check (push) Successful in 10s
Replace display:none with persistent visibility:hidden so the warning area occupies the same vertical space regardless of API result. This eliminates the layout shift that occurred when the container was collapsed after the recipient history check returned.
This commit is contained in:
@@ -246,7 +246,6 @@ function show(txInfo) {
|
|||||||
// Reset recipient warning: reserve space (visibility:hidden) while
|
// Reset recipient warning: reserve space (visibility:hidden) while
|
||||||
// the async check runs, preventing layout shift per README policy.
|
// the async check runs, preventing layout shift per README policy.
|
||||||
const recipientWarning = $("confirm-recipient-warning");
|
const recipientWarning = $("confirm-recipient-warning");
|
||||||
recipientWarning.style.display = "";
|
|
||||||
recipientWarning.style.visibility = "hidden";
|
recipientWarning.style.visibility = "hidden";
|
||||||
|
|
||||||
estimateGas(txInfo);
|
estimateGas(txInfo);
|
||||||
@@ -302,22 +301,18 @@ async function checkRecipientHistory(txInfo) {
|
|||||||
// the nonce, i.e. sent-tx count only).
|
// the nonce, i.e. sent-tx count only).
|
||||||
const code = await provider.getCode(txInfo.to);
|
const code = await provider.getCode(txInfo.to);
|
||||||
if (code && code !== "0x") {
|
if (code && code !== "0x") {
|
||||||
// Contract address — hide the reserved space entirely
|
// Contract address — no warning needed, keep space reserved
|
||||||
el.style.display = "none";
|
// but invisible to prevent layout shift
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const txCount = await provider.getTransactionCount(txInfo.to);
|
const txCount = await provider.getTransactionCount(txInfo.to);
|
||||||
if (txCount === 0) {
|
if (txCount === 0) {
|
||||||
el.style.visibility = "visible";
|
el.style.visibility = "visible";
|
||||||
} else {
|
|
||||||
// Address has history — collapse the reserved space
|
|
||||||
el.style.display = "none";
|
|
||||||
}
|
}
|
||||||
|
// If txCount > 0, leave visibility:hidden — space stays reserved
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
log.errorf("recipient history check failed:", e.message);
|
log.errorf("recipient history check failed:", e.message);
|
||||||
// On error, collapse the reserved space rather than showing a
|
// On error, leave visibility:hidden — no layout shift, no false warning
|
||||||
// false warning or leaving an empty gap
|
|
||||||
el.style.display = "none";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user