@@ -336,6 +336,22 @@ const EntityTable: React.FC<EntityTableProps> = ({
336336 } ;
337337 } , [ editingItem , isAddingItem , newItem , handleAddItem , handleSaveEditedItem ] ) ;
338338
339+ const nameRefs = useRef < ( HTMLDivElement | null ) [ ] > ( [ ] ) ;
340+ const abbreviationRefs = useRef < ( HTMLDivElement | null ) [ ] > ( [ ] ) ;
341+ const [ nameTooltipStates , setNameTooltipStates ] = useState < boolean [ ] > ( [ ] ) ;
342+ const [ abbrTooltipStates , setAbbrTooltipStates ] = useState < boolean [ ] > ( [ ] ) ;
343+
344+ useEffect ( ( ) => {
345+ const nameStates = nameRefs . current . map ( ( el ) =>
346+ el ? el . scrollWidth > el . clientWidth : false
347+ ) ;
348+ const abbrStates = abbreviationRefs . current . map ( ( el ) =>
349+ el ? el . scrollWidth > el . clientWidth : false
350+ ) ;
351+ setNameTooltipStates ( nameStates ) ;
352+ setAbbrTooltipStates ( abbrStates ) ;
353+ } , [ items ] ) ;
354+
339355 return (
340356 < Box borderWidth = "1px" borderRadius = "md" overflow = "hidden" >
341357 { /* Table Header */ }
@@ -446,7 +462,7 @@ const EntityTable: React.FC<EntityTableProps> = ({
446462 </ Box >
447463
448464 { /* Table Rows */ }
449- { sortedItems . map ( ( item ) => (
465+ { sortedItems . map ( ( item , index ) => (
450466 < Box
451467 px = { 4 }
452468 py = { 2 }
@@ -656,7 +672,7 @@ const EntityTable: React.FC<EntityTableProps> = ({
656672 label = { item . name }
657673 placement = "top"
658674 openDelay = { 300 }
659- isDisabled = { item . name . length <= 20 }
675+ isDisabled = { ! nameTooltipStates [ index ] }
660676 hasArrow
661677 >
662678 < Box
@@ -666,6 +682,9 @@ const EntityTable: React.FC<EntityTableProps> = ({
666682 flex = { 1 }
667683 >
668684 < Text
685+ ref = { ( el ) => {
686+ nameRefs . current [ index ] = el ;
687+ } }
669688 color = {
670689 item . archived ? 'text.inactiveButtonText' : 'inherit'
671690 }
@@ -707,11 +726,14 @@ const EntityTable: React.FC<EntityTableProps> = ({
707726 label = { item . abbreviation }
708727 placement = "top"
709728 openDelay = { 300 }
710- isDisabled = { item . abbreviation . length <= 3 }
729+ isDisabled = { ! abbrTooltipStates [ index ] }
711730 hasArrow
712731 >
713732 < Box position = "relative" overflow = "hidden" flex = { 1 } >
714733 < Text
734+ ref = { ( el ) => {
735+ abbreviationRefs . current [ index ] = el ;
736+ } }
715737 color = {
716738 item . archived ? 'text.inactiveButtonText' : 'inherit'
717739 }
0 commit comments