From e4e07ad7e8cf321c003589a1f2ee1d4a1cd55a22 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 04:27:16 +0000 Subject: [PATCH] fix(qrcode): calculate margins using real size instead of DOM offset Replaces the dependency on `offsetWidth` and `offsetHeight` with a deterministic calculation based on module count and cell size. This prevents incorrect (huge) margins when the QR code is generated inside a hidden container where offset dimensions are 0. Fixes: Margin values calculation in QRCode drawing logic. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- js/utils/qrcode.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/utils/qrcode.js b/js/utils/qrcode.js index 20bb2932..5e1d7abd 100644 --- a/js/utils/qrcode.js +++ b/js/utils/qrcode.js @@ -364,8 +364,8 @@ if (hasDocument) { // Fix the margin values as real size. var elTable = _el.childNodes[0]; - var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2; - var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2; + var nLeftMarginTable = (_htOption.width - (nCount * nWidth)) / 2; + var nTopMarginTable = (_htOption.height - (nCount * nHeight)) / 2; if (nLeftMarginTable > 0 && nTopMarginTable > 0) { updateQrCodeContainerStyles(_el, {