Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix annotation popover regression #1031

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Zotero/Scenes/Detail/PDF/Views/PDFDocumentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -509,8 +509,7 @@ final class PDFDocumentViewController: UIViewController {
private func select(annotation: PDFAnnotation, pageIndex: PageIndex, document: PSPDFKit.Document) {
guard let pdfController,
let pageView = updateSelectionOnVisiblePages(of: pdfController, annotation: annotation) ?? pdfController.pageViewForPage(at: pageIndex),
let pdfAnnotation = document.annotation(on: Int(pageView.pageIndex), with: annotation.key),
pageView.selectedAnnotations.contains(pdfAnnotation)
let pdfAnnotation = document.annotation(on: Int(pageView.pageIndex), with: annotation.key)
else { return }
pageView.selectedAnnotations = [pdfAnnotation]
}
Expand Down Expand Up @@ -958,7 +957,16 @@ extension PDFDocumentViewController: UIPencilInteractionDelegate {
}
}

extension PDFDocumentViewController: UIPopoverPresentationControllerDelegate { }
extension PDFDocumentViewController: UIPopoverPresentationControllerDelegate {
func presentationControllerDidDismiss(_ presentationController: UIPresentationController) {
guard let presentedNavigationController = presentationController.presentedViewController as? NavigationViewController,
(presentedNavigationController.children.first as? AnnotationPopoverViewController) != nil,
let type = viewModel.state.selectedAnnotation?.type,
type == .highlight || type == .underline
else { return }
viewModel.process(action: .deselectSelectedAnnotation)
}
}

extension PDFDocumentViewController: AnnotationBoundingBoxConverter {
/// Converts from database to PSPDFKit rect. Database stores rects in RAW PDF Coordinate space. PSPDFKit works with Normalized PDF Coordinate Space.
Expand Down