diff --git a/frontend/components/feedback-task/container/fields/span-annotation/components/EntityComponent.vue b/frontend/components/feedback-task/container/fields/span-annotation/components/EntityComponent.vue index ccdae505b9..7c53bbdbcb 100644 --- a/frontend/components/feedback-task/container/fields/span-annotation/components/EntityComponent.vue +++ b/frontend/components/feedback-task/container/fields/span-annotation/components/EntityComponent.vue @@ -79,11 +79,8 @@ export default { position.top + this.$refs.spanEntityRef.scrollTop }px`; }, - getScrollParent(element) { - if (!element) { - return undefined; - } + if (!element) return; let parent = element.parentElement; while (parent) { @@ -91,6 +88,7 @@ export default { if (overflow.split(" ").every((o) => o === "auto" || o === "scroll")) { return parent; } + parent = parent.parentElement; } @@ -98,6 +96,8 @@ export default { }, }, mounted() { + this.scroll = this.getScrollParent(document.getElementById("spanEntity")); + if (this.scroll) { this.scroll.addEventListener("scroll", this.getPosition); } @@ -107,9 +107,6 @@ export default { this.scroll.removeEventListener("scroll", this.getPosition); } }, - created() { - this.scroll = this.getScrollParent(document.getElementById("spanEntity")); - }, }; diff --git a/frontend/components/feedback-task/container/fields/span-annotation/components/highlighting.ts b/frontend/components/feedback-task/container/fields/span-annotation/components/highlighting.ts index 594afd1514..46bd05274e 100644 --- a/frontend/components/feedback-task/container/fields/span-annotation/components/highlighting.ts +++ b/frontend/components/feedback-task/container/fields/span-annotation/components/highlighting.ts @@ -87,6 +87,12 @@ export class Highlighting { } mount(selections: Omit[] = []) { + if (!CSS.highlights) { + throw new Error( + "The CSS Custom Highlight API is not supported in this browser!" + ); + } + const node = document.getElementById(this.nodeId)!; if (!node) throw new Error(`Node with id ${this.nodeId} not found`); @@ -105,12 +111,6 @@ export class Highlighting { } private loadHighlights(selections: Omit[] = []) { - if (!CSS.highlights) { - throw new Error( - "The CSS Custom Highlight API is not supported in this browser!" - ); - } - if (!this.node) { throw new Error( "Node not attached, use `attachNode` method with HTMLElement that contains the text to select" @@ -150,18 +150,13 @@ export class Highlighting { const nodeParent = node.parentNode; nodeParent.appendChild(this.entitySpanContainer.cloneNode(true)); - this.node.addEventListener("mouseup", () => { + this.node.addEventListener("click", () => { this.highlightUserSelection(); this.applyStyles(); }); - new ResizeObserver(() => updateStyles()).observe(node); - - const updateStyles = () => { - this.applyEntityStyle(); - this.applyStylesOnScroll(); - }; + new ResizeObserver(() => this.applyStyles()).observe(node); this.applyStylesOnScroll(); } diff --git a/frontend/components/feedback-task/container/questions/form/span/SpanComponent.vue b/frontend/components/feedback-task/container/questions/form/span/SpanComponent.vue index 2886166aae..5866d03d67 100644 --- a/frontend/components/feedback-task/container/questions/form/span/SpanComponent.vue +++ b/frontend/components/feedback-task/container/questions/form/span/SpanComponent.vue @@ -10,10 +10,6 @@ @on-focus="onFocus" @on-selected="onSelected" /> -
-

Values

- {{ JSON.stringify(question.answer.valuesAnswered) }} -