diff --git a/src/components/PricingView.tsx b/src/components/PricingView.tsx index 1cc4ae8..8663490 100644 --- a/src/components/PricingView.tsx +++ b/src/components/PricingView.tsx @@ -53,63 +53,12 @@ function findCol(headers: string[], ...keywords: string[]): number { ); } -function NoteTooltip({ note, isAnna, children }: { note: string, isAnna?: boolean, children: React.ReactNode }) { - const [show, setShow] = useState(false); - const [pos, setPos] = useState({ top: 0, left: 0 }); - const ref = useRef(null); - - if (!note) { - return <>{children}; - } - - const handleMouseEnter = () => { - if (ref.current) { - const rect = ref.current.getBoundingClientRect(); - setPos({ - top: rect.bottom + window.scrollY + 8, - left: rect.left + window.scrollX + rect.width / 2 - }); - setShow(true); - } - }; - - useEffect(() => { - const handleScroll = () => setShow(false); - if (show) { - window.addEventListener('scroll', handleScroll, true); - } - return () => window.removeEventListener('scroll', handleScroll, true); - }, [show]); - - return ( -
setShow(false)} - > - {children} - {show && createPortal( -
- {note} -
, - document.body - )} -
- ); -} - export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, rowStatuses }: PricingViewProps) { const COLUMNS = useColumns(); const [filterMode, setFilterMode] = usePersistentState('pricing-filterMode', 'all_errors'); const [search, setSearch] = usePersistentState('pricing-search', ''); const [currentPage, setCurrentPage] = useState(1); + const [hoveredNote, setHoveredNote] = useState<{ text: string, pos: { top: number, left: number }, isAnna: boolean } | null>(null); const pageSize = 100; const [columnWidths, setColumnWidths] = useState>({ articleNo: 100, @@ -928,6 +877,20 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, document.body )} + {/* ── Tooltip Portal ── */} + {hoveredNote && createPortal( +
+ {hoveredNote.text} +
, + document.body + )} +
{/* ── Search bar with Dropdown ── */}
@@ -1980,19 +1943,27 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, onChange={(e) => handleToggleCheck(dataIndex, e.target.checked)} className="w-4 h-4 rounded border-slate-600 bg-slate-900 text-blue-600 focus:ring-blue-500 focus:ring-offset-slate-800 cursor-pointer" /> - - - +
@@ -2009,19 +1980,27 @@ export function PricingView({ data, headers, onSaveRow, onCaptureState, onEdit, onChange={(e: React.ChangeEvent) => handleToggleAnnaCheck(dataIndex, e.target.checked)} className="w-4 h-4 rounded border-slate-600 bg-slate-900 text-pink-600 focus:ring-pink-500 focus:ring-offset-slate-800 cursor-pointer" /> - - - +
);