Skip to content

Stop annotations target being rewritten from items - #696

Merged
JackLewis-digirati merged 3 commits into
developfrom
fix/retargetOnlyModifiedCanvas
Oct 1, 2026
Merged

JackLewis-digirati merged 3 commits into
developfrom
fix/retargetOnlyModifiedCanvas

Conversation

@JackLewis-digirati

@JackLewis-digirati JackLewis-digirati commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

What does this change?

Resolves #694

This PR modifies how target is rewritten, so it rewrites a named query canvas before adding it, instead of working across all canvases after they've been added to the manifest. This means annotations set by the customer are left alone

@JackLewis-digirati

JackLewis-digirati commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator Author

How this fixes #694

The problem: after copying the named-query (NQ) canvas's annotation pages onto the canvas/manifest, AddRetargetedAnnotations looped over every annotation page on the resource. It retargeted any inline annotation that pointed at the NQ canvas. On a mixed manifest that includes pages the user supplied via items (or directly on the manifest), so a user annotation that deliberately targets the NQ canvas had its target silently rewritten.

The fix: the loop now runs over the NQ canvas's pages rather than the resource's pages. Pages already on the resource are never modified. For each NQ page:

  • A page with the same id is already on the resource: it's skipped, and the existing page is left exactly as it is.
  • Otherwise: the NQ page is cloned, retargeted and added. NQ pages are shared between every canvas the asset is painted on, so they're always cloned before modification.

The per-page retargeting (canvas target / #fragment / SpecificResource.Source, or the whole manifest for manifest-level adjuncts) is unchanged. It has moved into its own RetargetAnnotations method.

Behaviour changes:

Tests:

  • New: ProcessCanvasPaintings_DoesNotRetargetExistingInlineAnnotation_NotFromNamedQueryCanvas (canvas level) and MergeManifest_DoesNotRetargetExistingInlineAnnotation_NotFromStubCanvas (manifest level). In both, a user page targets the NQ/stub canvas: the user page keeps its target and the NQ page is still retargeted.
  • Flipped from Set the target to correctly point towards the canvas or the manifest #689: ProcessCanvasPaintings_DoesNotRetargetExistingInlineAnnotationAdjunct_TargetingNamedQueryCanvas and MergeManifest_DoesNotRetargetExistingInlineAnnotation_TargetingStubCanvas. An existing page with the same id as an NQ page keeps its original target.

@JackLewis-digirati
JackLewis-digirati force-pushed the fix/retargetOnlyModifiedCanvas branch from 82afdd3 to 0c8bfc1 Compare September 30, 2026 13:15
@JackLewis-digirati
JackLewis-digirati marked this pull request as ready for review September 30, 2026 13:52
@JackLewis-digirati
JackLewis-digirati requested a review from a team as a code owner September 30, 2026 13:52
Comment thread src/IIIFPresentation/Services/Manifests/ManifestMerger.cs Outdated
Comment thread src/IIIFPresentation/Services/Manifests/ManifestMerger.cs Outdated
Comment thread src/IIIFPresentation/Services/Manifests/ManifestMerger.cs Outdated
- Remove nullable warning
- Modify comment
@JackLewis-digirati
JackLewis-digirati merged commit f1d5c3c into develop Oct 1, 2026
4 checks passed
@JackLewis-digirati
JackLewis-digirati deleted the fix/retargetOnlyModifiedCanvas branch October 1, 2026 10:35
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.

AddRetargetedAnnotations retargets all canvases, when it should only retarget items from the named query

2 participants