|
1 | 1 | import { HpoAnnotationDto, ParentChildDto, TextAnnotationDto, textAnnotationToHpoAnnotation, to_annotation_dto } from '../models/text_annotation_dto'; |
2 | 2 | import { AgeInputService } from '../services/age_service'; |
3 | 3 | import { CommonModule } from '@angular/common'; |
4 | | -import { Component, Input, Output, EventEmitter, OnInit, inject, signal } from '@angular/core'; |
| 4 | +import { Component, Input, Output, EventEmitter, OnInit, inject, signal, ElementRef, ViewChild, HostListener } from '@angular/core'; |
5 | 5 | import { FormsModule } from '@angular/forms'; |
6 | 6 | import { openUrl } from '@tauri-apps/plugin-opener'; |
7 | 7 | import { ConfigService } from '../services/config.service'; |
@@ -30,6 +30,7 @@ export class HpoPolishingComponent implements OnInit { |
30 | 30 | private configService = inject(ConfigService); |
31 | 31 | private dialog = inject(MatDialog); |
32 | 32 | private notificationService = inject(NotificationService); |
| 33 | + @ViewChild('annotationTable') annotationTable!: ElementRef; |
33 | 34 |
|
34 | 35 | availableOnsetTerms = this.ageService.selectedTerms; |
35 | 36 | hpoAnnotations = signal<HpoAnnotationDto[]>([]); |
@@ -120,6 +121,14 @@ export class HpoPolishingComponent implements OnInit { |
120 | 121 | } |
121 | 122 | } |
122 | 123 |
|
| 124 | + @HostListener('document:mousedown', ['$event']) // mousedown is often more reliable than click |
| 125 | + onGlobalClick(event: MouseEvent): void { |
| 126 | + const clickedInside = this.annotationTable.nativeElement.contains(event.target); |
| 127 | + if (!clickedInside) { |
| 128 | + this.showDropdownMap = {}; |
| 129 | + } |
| 130 | + } |
| 131 | + |
123 | 132 | /** This is used in the GUI to replace a term by a parent or child term. */ |
124 | 133 | replaceTerm(annotation: HpoAnnotationDto, replacement: HpoAnnotationDto) { |
125 | 134 | this.hpoAnnotations.update(current => { |
|
0 commit comments