fix(main): pass rect to setMode and remove redundant _positionAnchored call (anchor crash fix)

This commit is contained in:
dev
2026-06-07 09:00:04 -05:00
parent 95c655c24c
commit 2ed25c14de
2 changed files with 8 additions and 7 deletions
+7 -7
View File
@@ -100,13 +100,13 @@ function start() {
const el = findAnchorElement();
if (el) {
const rect = el.getBoundingClientRect();
dialog.setMode('anchored', { canAnchor: true });
dialog._positionAnchored(rect);
// observe
const ro = new ResizeObserver(() => {
if (prefs.mode === 'anchored') dialog._positionAnchored(el.getBoundingClientRect());
});
ro.observe(el);
dialog.setMode('anchored', { canAnchor: true, rect: rect });
if (typeof ResizeObserver !== 'undefined') {
const ro = new ResizeObserver(function () {
if (prefs.mode === 'anchored') dialog._positionAnchored(el.getBoundingClientRect());
});
ro.observe(el);
}
anchorError = null;
return;
}
+1
View File
@@ -135,6 +135,7 @@ export class Dialog {
}
_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;