RED-3603, RED-3710: arrow navigation, again

This commit is contained in:
Adina Țeudan 2022-03-28 19:10:58 +03:00
parent 6ff0f0be05
commit 3bdbb1e4c6

View File

@ -194,9 +194,20 @@ export class PdfViewerComponent extends AutoUnsubscribe implements OnInit, OnCha
await this._configureTextPopup();
this.annotationManager.addEventListener('annotationSelected', async (annotations: Annotation[], action) => {
const nextAnnotations = this.multiSelectService.isEnabled ? this.annotationManager.getSelectedAnnotations() : annotations;
let nextAnnotations: Annotation[];
if (action === 'deselected') {
// Remove deselected annotations from selected list
nextAnnotations = this.annotationManager.getSelectedAnnotations().filter(ann => !annotations.find(a => a.Id === ann.Id));
} else if (!this.multiSelectService.isEnabled) {
// Only choose the last selected annotation, to bypass viewer multi select
nextAnnotations = annotations;
} else {
// Get selected annotations from the manager, no intervention needed
nextAnnotations = this.annotationManager.getSelectedAnnotations();
}
this.annotationSelected.emit(nextAnnotations.map(ann => ann.Id));
this.annotationSelected.emit(action === 'selected' ? nextAnnotations.map(ann => ann.Id) : []);
if (action === 'deselected') {
return this._toggleRectangleAnnotationAction(true);
}