From cc0b58c5d986721455076ba149a166b54efd9c1b Mon Sep 17 00:00:00 2001
From: Maxime Jacquemin <maxime2.jacquemin@gmail.com>
Date: Wed, 30 Mar 2022 11:57:22 +0200
Subject: [PATCH] [ivette] A better solution to text selection

---
 ivette/src/frama-c/plugins/eva/valuetable.tsx | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/ivette/src/frama-c/plugins/eva/valuetable.tsx b/ivette/src/frama-c/plugins/eva/valuetable.tsx
index 0b240e28797..45208eaa721 100644
--- a/ivette/src/frama-c/plugins/eva/valuetable.tsx
+++ b/ivette/src/frama-c/plugins/eva/valuetable.tsx
@@ -648,15 +648,9 @@ async function FunctionSection(props: FunctionProps): Promise<JSX.Element> {
   const displayTable = folded || !(before || after) ? 'none' : 'table';
   type RowHandler = React.MouseEventHandler<HTMLTableRowElement>;
   const onClick: (c: callstack) => RowHandler = (c) => (event) => {
-    const target = event.currentTarget;
-    const selection = document.getSelection();
-    const length = selection?.toString()?.length ?? 0;
-    const container = selection?.anchorNode;
-    const row = container?.parentElement?.parentElement?.parentElement;
-    if (target !== row || length === 0)
+    const elt = document.elementFromPoint(event.clientX, event.clientY);
+    if (elt?.localName !== 'span')
       props.selectCallstack(isSelectedCallstack(c) ? 'Summary' : c);
-    if (target !== row && target.parentElement === row?.parentElement)
-      selection?.collapse(null);
   };
 
   /* Computes the relevant callstacks */
-- 
GitLab