Skip to content

Commit 53d0211

Browse files
committed
fix pdf window focus
1 parent c936357 commit 53d0211

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/components/FloatingWindow.vue

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,26 @@ function onWindowClickForMenu(e: MouseEvent) {
133133
menuOpen.value = false
134134
}
135135
136+
// Clicks inside an <iframe> (e.g. the PDF preview) never bubble a pointerdown
137+
// here, since it's a separate browsing context — but focusing it does blur
138+
// the top-level window, so use that as a fallback focus signal.
139+
function onWindowBlur() {
140+
setTimeout(() => {
141+
if (document.activeElement instanceof HTMLIFrameElement && rootEl.value?.contains(document.activeElement)) {
142+
emit('focus')
143+
}
144+
}, 0)
145+
}
146+
136147
onMounted(() => {
137148
document.addEventListener('fullscreenchange', onFullscreenChange)
138149
window.addEventListener('click', onWindowClickForMenu, true)
150+
window.addEventListener('blur', onWindowBlur)
139151
})
140152
onUnmounted(() => {
141153
document.removeEventListener('fullscreenchange', onFullscreenChange)
142154
window.removeEventListener('click', onWindowClickForMenu, true)
155+
window.removeEventListener('blur', onWindowBlur)
143156
})
144157
145158
function suppressSelection() {

0 commit comments

Comments
 (0)