diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index bf3b3e793..91cc8a1c9 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -1736,35 +1736,31 @@ class ChoiceWidgetAnnotationElement extends WidgetAnnotationElement { } 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) { - const isRenderable = !!( - parameters.data.titleObj?.str || - parameters.data.contentsObj?.str || - parameters.data.richText?.str - ); + const { data } = parameters; + const isRenderable = + !PopupAnnotationElement.IGNORE_TYPES.has(data.parentType) && + !!(data.titleObj?.str || data.contentsObj?.str || data.richText?.str); super(parameters, { isRenderable }); } 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"; - if (IGNORE_TYPES.includes(this.data.parentType)) { - return this.container; - } - - const selector = `[data-annotation-id="${this.data.parentId}"]`; - const parentElements = this.layer.querySelectorAll(selector); + const parentElements = this.layer.querySelectorAll( + `[data-annotation-id="${this.data.parentId}"]` + ); if (parentElements.length === 0) { return this.container; }