1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-08-13 13:48:59 +02:00

refactor: tooltip title variable name

This commit is contained in:
Tymoteusz Czech 2025-07-29 20:26:31 +02:00
parent 3479aa8b2c
commit e684cc61c0
No known key found for this signature in database
GPG Key ID: 133555230D88D75F

View File

@ -52,7 +52,7 @@ export const CellSortable: FC<ICellSortableProps> = ({
styles, styles,
}) => { }) => {
const { setAnnouncement } = useContext(AnnouncerContext); const { setAnnouncement } = useContext(AnnouncerContext);
const [title, setTitle] = useState(''); const [tooltipTitle, setTooltipTitle] = useState('');
const ref = useRef<HTMLSpanElement>(null); const ref = useRef<HTMLSpanElement>(null);
const ariaSort = isSorted const ariaSort = isSorted
@ -93,17 +93,17 @@ export const CellSortable: FC<ICellSortableProps> = ({
}, [align]); }, [align]);
useEffect(() => { useEffect(() => {
const newTitle = const newTooltipTitle =
ariaTitle && ariaTitle &&
ref.current && ref.current &&
ref?.current?.offsetWidth < ref?.current?.scrollWidth ref?.current?.offsetWidth < ref?.current?.scrollWidth
? `${children}` ? `${children}`
: ''; : '';
if (newTitle !== title) { if (newTooltipTitle !== tooltipTitle) {
setTitle(newTitle); setTooltipTitle(newTooltipTitle);
} }
}, [setTitle, ariaTitle]); }, [setTooltipTitle, ariaTitle]);
return ( return (
<StyledTableCell <StyledTableCell
@ -117,7 +117,7 @@ export const CellSortable: FC<ICellSortableProps> = ({
<ConditionallyRender <ConditionallyRender
condition={isSortable} condition={isSortable}
show={ show={
<Tooltip title={title} arrow> <Tooltip title={tooltipTitle} arrow>
<StyledButton <StyledButton
isSorted={isSorted} isSorted={isSorted}
type='button' type='button'