From 32d272fd8c551f416d9d82e140dfd31658327c8e Mon Sep 17 00:00:00 2001 From: Sara Date: Tue, 19 Dec 2023 20:04:44 +0100 Subject: [PATCH] fix double-click word --- .../[transcriptId]/correct/topicWords.tsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx b/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx index d001067e..0c420463 100644 --- a/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx +++ b/www/app/[domain]/transcripts/[transcriptId]/correct/topicWords.tsx @@ -23,7 +23,6 @@ const topicWords = ({ useEffect(() => { if (topicWithWords.loading && selectedTextIsTimeSlice(selectedText)) { setSelectedText(undefined); - console.log("unsetting topic changed"); } }, [topicWithWords.loading]); @@ -94,13 +93,15 @@ const topicWords = ({ ); // if selection end on a word, we get the end time from the span that contains it const focusEnd = - selection.focusNode.parentElement?.dataset["end"] || - // otherwise it was a name and we get the end of the last word of the previous paragraph - ( - selection.focusNode.parentElement?.parentElement - ?.previousElementSibling?.lastElementChild as any - )?.dataset["end"] || - 0; + selection.focusOffset !== 0 + ? selection.focusNode.parentElement?.dataset["end"] || + // otherwise it was a name and we get the end of the last word of the previous paragraph + ( + selection.focusNode.parentElement?.parentElement + ?.previousElementSibling?.lastElementChild as any + )?.dataset["end"] + : (selection.focusNode.parentElement?.previousElementSibling as any) + ?.dataset["end"] || 0; const reverse = parseFloat(anchorStart) >= parseFloat(focusEnd);