fix(client/pdf): not always focusing on click
Some checks are pending
Checks / main (push) Waiting to run
CodeQL Advanced / Analyze (actions) (push) Waiting to run
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Dev / Test development (push) Waiting to run
Dev / Build Docker image (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile) (push) Blocked by required conditions
Dev / Check Docker build (Dockerfile.alpine) (push) Blocked by required conditions
/ Check Docker build (Dockerfile) (push) Waiting to run
/ Check Docker build (Dockerfile.alpine) (push) Waiting to run
/ Build Docker images (Dockerfile, ubuntu-24.04-arm, linux/arm64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.alpine, ubuntu-latest, linux/amd64) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v7) (push) Blocked by required conditions
/ Build Docker images (Dockerfile.legacy, ubuntu-24.04-arm, linux/arm/v8) (push) Blocked by required conditions
/ Merge manifest lists (push) Blocked by required conditions
playwright / E2E tests on linux-arm64 (push) Waiting to run
playwright / E2E tests on linux-x64 (push) Waiting to run

This commit is contained in:
Elian Doran 2026-01-02 21:20:29 +02:00
parent 0c1859dc43
commit e161ffce57
No known key found for this signature in database

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);
});
}
}}
/>
);