Merge pull request #15360 from Snuffleupagus/Popup-IGNORE_TYPES
Properly ignore PopupAnnotations with custom `trigger`-elements
This commit is contained in:
commit
783c722661
@ -1736,35 +1736,31 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class PopupAnnotationElement extends AnnotationElement {
|
class PopupAnnotationElement extends AnnotationElement {
|
||||||
|
// Do not render popup annotations for parent elements with these types as
|
||||||
|
// they create the popups themselves (because of custom trigger divs).
|
||||||
|
static IGNORE_TYPES = new Set([
|
||||||
|
"Line",
|
||||||
|
"Square",
|
||||||
|
"Circle",
|
||||||
|
"PolyLine",
|
||||||
|
"Polygon",
|
||||||
|
"Ink",
|
||||||
|
]);
|
||||||
|
|
||||||
constructor(parameters) {
|
constructor(parameters) {
|
||||||
const isRenderable = !!(
|
const { data } = parameters;
|
||||||
parameters.data.titleObj?.str ||
|
const isRenderable =
|
||||||
parameters.data.contentsObj?.str ||
|
!PopupAnnotationElement.IGNORE_TYPES.has(data.parentType) &&
|
||||||
parameters.data.richText?.str
|
!!(data.titleObj?.str || data.contentsObj?.str || data.richText?.str);
|
||||||
);
|
|
||||||
super(parameters, { isRenderable });
|
super(parameters, { isRenderable });
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// Do not render popup annotations for parent elements with these types as
|
|
||||||
// they create the popups themselves (because of custom trigger divs).
|
|
||||||
const IGNORE_TYPES = [
|
|
||||||
"Line",
|
|
||||||
"Square",
|
|
||||||
"Circle",
|
|
||||||
"PolyLine",
|
|
||||||
"Polygon",
|
|
||||||
"Ink",
|
|
||||||
];
|
|
||||||
|
|
||||||
this.container.className = "popupAnnotation";
|
this.container.className = "popupAnnotation";
|
||||||
|
|
||||||
if (IGNORE_TYPES.includes(this.data.parentType)) {
|
const parentElements = this.layer.querySelectorAll(
|
||||||
return this.container;
|
`[data-annotation-id="${this.data.parentId}"]`
|
||||||
}
|
);
|
||||||
|
|
||||||
const selector = `[data-annotation-id="${this.data.parentId}"]`;
|
|
||||||
const parentElements = this.layer.querySelectorAll(selector);
|
|
||||||
if (parentElements.length === 0) {
|
if (parentElements.length === 0) {
|
||||||
return this.container;
|
return this.container;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user