Skip to content

Commit ef1904e

Browse files
Label box position fix
1 parent 3e65062 commit ef1904e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/components/projects/projectId/labeling/sessionId/sub-components/LabelingSuiteLabeling.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ export default function LabelingSuiteLabeling() {
118118
clearSelected();
119119
} else {
120120
window.getSelection().empty();
121-
setSelected(attributeIdStart, tokenStart, tokenEnd, startEl);
121+
setSelected(attributeIdStart, tokenStart, tokenEnd, e, startEl);
122122
}
123123
};
124124
extractionRef.current.addEventListener('mouseup', handleMouseUp);
@@ -474,7 +474,7 @@ export default function LabelingSuiteLabeling() {
474474
dispatch(setActiveTokenSelection(null));
475475
}, [tokenLookup]);
476476

477-
function setSelected(attributeId: string, tokenStart: number, tokenEnd: number, e?: any) {
477+
function setSelected(attributeId: string, tokenStart: number, tokenEnd: number, e?: any, startEl?: DOMRect) {
478478
if (!canEditLabels && user.role != UserRole.ANNOTATOR && userDisplayRole != UserRole.ANNOTATOR) return;
479479
const tokenLookupCopy = jsonCopy(tokenLookup);
480480
if (!tokenLookupCopy[attributeId]) {
@@ -489,11 +489,11 @@ export default function LabelingSuiteLabeling() {
489489
setActiveTasksFuncRef.current(lVars.taskLookup[attributeId].lookup);
490490
}
491491
setTokenLookup(tokenLookupCopy);
492-
labelBoxPosition(e);
492+
labelBoxPosition(e, startEl);
493493
}
494494

495-
function labelBoxPosition(e) {
496-
const labelBox: DOMRect = e.target?.getBoundingClientRect();
495+
function labelBoxPosition(e, startEl?: DOMRect) {
496+
const labelBox: DOMRect = startEl || e.target.getBoundingClientRect();
497497
if (!labelBox) return;
498498
const baseBox: DOMRect = document.getElementById('base-dom-element')?.getBoundingClientRect();
499499
if (!baseBox) return;

0 commit comments

Comments
 (0)