mirror of
https://github.com/zadam/trilium.git
synced 2026-02-04 21:49:13 +01:00
fix(client/pdf): not always focusing on click
This commit is contained in:
@@ -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);
|
||||
});
|
||||
}
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user