fix(client/pdf): not always focusing on click

This commit is contained in:
Elian Doran
2026-01-02 21:20:29 +02:00
parent 0c1859dc43
commit e161ffce57

View File

@@ -151,25 +151,6 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
}
}, [ blob ]);
// Trigger focus when iframe content is clicked (iframe focus doesn't bubble)
useEffect(() => {
const iframe = iframeRef.current;
if (!iframe) return;
const handleIframeClick = () => {
if (noteContext.ntxId) {
appContext.tabManager.activateNoteContext(noteContext.ntxId);
}
};
// Listen for clicks on the iframe's content window
const iframeDoc = iframe.contentWindow?.document;
if (iframeDoc) {
iframeDoc.addEventListener('click', handleIframeClick);
return () => iframeDoc.removeEventListener('click', handleIframeClick);
}
}, [ iframeRef.current?.contentWindow, noteContext ]);
return (historyConfig &&
<iframe
tabIndex={300}
@@ -182,6 +163,12 @@ export default function PdfPreview({ note, blob, componentId, noteContext }: {
win.TRILIUM_VIEW_HISTORY_STORE = historyConfig.config;
}
onLoad();
if (iframeRef.current?.contentWindow) {
iframeRef.current.contentWindow.addEventListener('click', () => {
appContext.tabManager.activateNoteContext(noteContext.ntxId);
});
}
}}
/>
);