diff --git a/torn-attribute-tracker.user.js b/torn-attribute-tracker.user.js index a0206da..19780bf 100644 --- a/torn-attribute-tracker.user.js +++ b/torn-attribute-tracker.user.js @@ -356,6 +356,7 @@ else { this.root.style.top = '20px'; this.root.style.left = '50%'; this.root.style.transform = 'translateX(-50%)'; } } _positionAnchored(rect) { + if (!rect) return; // defensive: setMode may be called without a rect const dialogRect = this.root.getBoundingClientRect(); let top = rect.top - dialogRect.height - 8; if (top < 8) top = 20; @@ -516,8 +517,7 @@ const el = findAnchorElement(); if (el) { const rect = el.getBoundingClientRect(); - dialog.setMode('anchored', { canAnchor: true }); - dialog._positionAnchored(rect); + dialog.setMode('anchored', { canAnchor: true, rect: rect }); if (typeof ResizeObserver !== 'undefined') { const ro = new ResizeObserver(function () { if (prefs.mode === 'anchored') dialog._positionAnchored(el.getBoundingClientRect());