fix(main): pass rect to setMode and remove redundant _positionAnchored call (anchor crash fix)
This commit is contained in:
+4
-4
@@ -100,13 +100,13 @@ function start() {
|
|||||||
const el = findAnchorElement();
|
const el = findAnchorElement();
|
||||||
if (el) {
|
if (el) {
|
||||||
const rect = el.getBoundingClientRect();
|
const rect = el.getBoundingClientRect();
|
||||||
dialog.setMode('anchored', { canAnchor: true });
|
dialog.setMode('anchored', { canAnchor: true, rect: rect });
|
||||||
dialog._positionAnchored(rect);
|
if (typeof ResizeObserver !== 'undefined') {
|
||||||
// observe
|
const ro = new ResizeObserver(function () {
|
||||||
const ro = new ResizeObserver(() => {
|
|
||||||
if (prefs.mode === 'anchored') dialog._positionAnchored(el.getBoundingClientRect());
|
if (prefs.mode === 'anchored') dialog._positionAnchored(el.getBoundingClientRect());
|
||||||
});
|
});
|
||||||
ro.observe(el);
|
ro.observe(el);
|
||||||
|
}
|
||||||
anchorError = null;
|
anchorError = null;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -135,6 +135,7 @@ export class Dialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_positionAnchored(rect) {
|
_positionAnchored(rect) {
|
||||||
|
if (!rect) return; // defensive: setMode may be called without a rect
|
||||||
const dialogRect = this.root.getBoundingClientRect();
|
const dialogRect = this.root.getBoundingClientRect();
|
||||||
let top = rect.top - dialogRect.height - 8;
|
let top = rect.top - dialogRect.height - 8;
|
||||||
if (top < 8) top = 20;
|
if (top < 8) top = 20;
|
||||||
|
|||||||
Reference in New Issue
Block a user