fix: hoist filter should not catch sticky elements or oversized containers

- Remove position:sticky from hoist criteria (sticky is scroll-following, not popup)
- Add cover < 1.0 upper bound (real dialogs do not exceed viewport area)
This commit is contained in:
Liang Jiaqing
2026-04-07 10:17:55 +08:00
parent 054674baa1
commit b525684378

View File

@@ -291,10 +291,10 @@ function analyzeNode(node, pPathType='main') {
const _fc = [...domCopy.querySelectorAll('*')].filter(el => {
if (el.parentNode === domCopy) return false;
const info = getNodeInfo(el);
if (!info?.rect || (info.style.position !== 'fixed' && info.style.position !== 'sticky')) return false;
if (!info?.rect || info.style.position !== 'fixed') return false;
const r = info.rect, cover = (r.width * r.height) / viewportArea;
const cd = Math.abs((r.left + r.width/2) - window.innerWidth/2) / window.innerWidth;
return cover > 0.15 && cd < 0.3 && el.querySelector('button, input, a, [role="button"], iframe');
return cover > 0.15 && cover < 1.0 && cd < 0.3 && el.querySelector('button, input, a, [role="button"], iframe');
}).filter((el, _, arr) => !arr.some(o => o !== el && o.contains(el)))
.sort((a, b) => (getNodeInfo(b).rect.width * getNodeInfo(b).rect.height) - (getNodeInfo(a).rect.width * getNodeInfo(a).rect.height))
.slice(0, 2);