Skip to content

[MDS-7015] red boundary box not showing in pdf viewer for permit conditions - #3991

Merged
asinn134 merged 6 commits into
developfrom
mds-7015-red-boundasry-box-not-showing-in-pdf-viewer
Sep 15, 2026
Merged

asinn134 merged 6 commits into
developfrom
mds-7015-red-boundasry-box-not-showing-in-pdf-viewer

Conversation

@asinn134

@asinn134 asinn134 commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator

Objective

MDS-7015

  • The "Open Permit in Document Viewer" side-by-side PDF view in the permit conditions page wasn't scrolling to or highlighting the selected condition. The cause of this was the highlight/scroll logic only ran inside the PDF's one-time documentLoad event, so it fired at most once per viewer open and never updated as you clicked through different conditions. It also only worked if you had selected a condition before you clicked "Open Permit In Document Viewer" button.

  • The highlight/page-navigation now re-runs whenever the selected condition's page or bounding box actually changes, not just on the PDF's initial load.

  • The change also always clears the previous highlight before drawing the next one so there aren't any leftover bounding boxes just sticking around

  • Also locked the bounding boxes so the user can't drag them boxes around

simensma-fresh
simensma-fresh previously approved these changes Sep 8, 2026

@alazar-aot alazar-aot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting a few small tweaks to make things a bit tighter, but great work overall!

Comment on lines +133 to +152
useEffect(() => {
setIsDocumentLoaded(false);
hasDrawnAnnotationRef.current = false;
}, [documentPath]);

const { pageNumber, boundingBox } = annotationLocation ?? {};
const { top, right, bottom, left } = boundingBox ?? {};

useEffect(() => {
if (!isDocumentLoaded || !pdfViewerRef.current) {
return;
}

if (annotationLocation) {
hasDrawnAnnotationRef.current = true;
addAnnotationToPDFViewer(pdfViewerRef.current, pageNumber, boundingBox);
} else if (hasDrawnAnnotationRef.current) {
pdfViewerRef.current.annotation.clear();
}
}, [isDocumentLoaded, pageNumber, top, right, bottom, left]);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If documentPath and annotationLocation both change in the same render then I think it's possible that we end up drawing the annotation on the old/reloading PDF. Might be better to make isDocumentLoaded only true when pdfViewerRef.current corresponds to the currently loaded documentPath, or add documentPath to the annotation's useEffect dependency array directly (and re-check load state against it before calling addAnnotationToPDFViewer)

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been changed as well now

Comment thread services/common/src/components/syncfusion/pdfViewerAnnotations.ts
@asinn134
asinn134 requested a review from alazar-aot September 15, 2026 17:27
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Passed Quality Gate passed for 'bcgov-sonarcloud_mds_minespace-web'

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarQube Cloud

@sonarqubecloud

Copy link
Copy Markdown

@sonarqubecloud

Copy link
Copy Markdown

@alazar-aot alazar-aot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@asinn134
asinn134 merged commit 25a312b into develop Sep 15, 2026
16 checks passed
@asinn134
asinn134 deleted the mds-7015-red-boundasry-box-not-showing-in-pdf-viewer branch September 15, 2026 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants