thsi is my code for modifying the position of my tooltip so i t stays within the…
- User
thsi is my code for modifying the position of my tooltip so i t stays within the ancestor bounds. However, it seems to be really messing up the tooltip position. could transform used in the tooltip class be causing the issues? const Highlight = ({ children, id }: { children: React.ReactNode, id: string }) => { const [isVisible, setIsVisible] = useState(false); const tooltipRef = useRef<HTMLSpanElement | null>(null); const [tooltipStyles, setTooltipStyles] = useState({ left: 0 });
useEffect(() => { if (isVisible) { const tooltip = document.getElementById('ignore'+id) console.log(tooltip) if (tooltip) { const parent = document.getElementById(id); const ancestor = document.getElementById(MESSAGE_LIST_CONTAINER_ID+"ANNOT"); console.log(parent) console.log(ancestor) if (parent && ancestor) { const parentRect = parent.getBoundingClientRect(); const ancestorRect = ancestor.getBoundingClientRect(); const tooltipRect = tooltip.getBoundingClientRect();
console.log(tooltipRect) console.log("board rect") console.log(ancestorRect) let left = tooltipRect.right; let right = tooltipRect.left; //tooltip.style.display = 'block' if (tooltipRect.right > ancestorRect.right) { right = ancestorRect.right; //tooltip.style.right = `${right}px` console.log("right") } if (tooltipRect.left < ancestorRect.left) { left = ancestorRect.left; //tooltip.style.left = `${left}px`; console.log('left') } setTooltipStyles({ left: left }); console.log(left) console.log(right) } } }}, [isVisible, id]);
useEffect(() => { const tooltip = document.getElementById('ignore' + id); if (tooltip) { tooltip.style.left =
${tooltipStyles.left}px; } }, [tooltipStyles, id]);return ( <span id={id} className='highlight' onMouseEnter={() => setIsVisible(true)} onMouseLeave={() => setIsVisible(false)}> {children} {isVisible && ( <span id={'ignore'+id} className='tooltip' aria-hidden='true' style={{ position: 'absolute' /*right: tooltipStyles.right, left: tooltipStyles.left */}}> This is an annotation and its super cool!!! Blah blah blah. random test here. something something something. this is a text. )} ); };
- Assistant
- User
i am using react bt
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.