Native browser pages could cover application dialogs and overlapping menus or notifications. Suspend only the viewport while covered and restore the same active page afterward, including nested dialogs and terminal prompts. Keep knowledge source controls at their full height, constrain long library cards and titles, and update automatic names when switching remote targets without overwriting edited or saved names. Restore packaged release-note loading now that the history exceeds its previous size limit. Add focused regressions and real Electron UI evidence. Clean up temporary Harness fixture directories at test completion instead of accumulating them. Release note: 修复内嵌浏览器遮挡弹窗和浮层、知识库来源选项被压缩及长名称显示异常;切换远端知识库时自动名称正确更新,并恢复更新说明显示。
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
export const browserOverlaySelector = [
|
|
'[aria-modal="true"]',
|
|
'[role="dialog"]',
|
|
'[role="alertdialog"]',
|
|
'[role="menu"]',
|
|
'.app-notification'
|
|
].join(', ')
|
|
|
|
export function isBrowserViewportOccluded(
|
|
host: HTMLElement,
|
|
viewport: DOMRect
|
|
): boolean {
|
|
// WebContentsView is above the renderer, regardless of CSS z-index.
|
|
// Release its viewport, not its session, while renderer overlays need it.
|
|
return Array.from(
|
|
host.ownerDocument.querySelectorAll<HTMLElement>(browserOverlaySelector)
|
|
).some((overlay) => {
|
|
if (overlay.contains(host) || overlay.closest('[hidden]')) return false
|
|
const rect = overlay.getBoundingClientRect()
|
|
if (rect.width < 1 || rect.height < 1) return false
|
|
const style = getComputedStyle(overlay)
|
|
if (style.visibility === 'hidden' || style.visibility === 'collapse') {
|
|
return false
|
|
}
|
|
for (let element: HTMLElement | null = overlay; element; element = element.parentElement) {
|
|
if (getComputedStyle(element).display === 'none') return false
|
|
}
|
|
return overlay.getAttribute('aria-modal') === 'true' || (
|
|
rect.left < viewport.right &&
|
|
rect.right > viewport.left &&
|
|
rect.top < viewport.bottom &&
|
|
rect.bottom > viewport.top
|
|
)
|
|
})
|
|
}
|