fix: stabilize tooltip anchor ID with useRef to prevent hover glitch (#21888)
## Context Tooltip components were generating a new anchor ID on every render. This caused a flicker/glitch when hovering: the tooltip would briefly disappear and reappear because React reconciled the changed ID as a different element. ## Solution Changed the anchor ID generation from inline (re-created every render) to `useRef` (stable across renders). The ID is now created once on mount and stays the same for the lifetime of the component. ## Test plan - [x] Hover over any element with a tooltip — no flicker or disappear/reappear behavior - [x] Multiple tooltips on the same page still work independently 🤖 Generated with [Claude Code](https://claude.ai/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/twentyhq/twenty/pull/21888?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. --> --------- Co-authored-by: Emmanuel Hernandez <emmanuel.hernandez@clickbalance.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
committed by
GitHub
parent
ee71a382de
commit
981ee6a2d7
+9
-3
@@ -1,7 +1,13 @@
|
||||
import { SKELETON_LOADER_HEIGHT_SIZES } from '@/activities/components/SkeletonLoader';
|
||||
import { styled } from '@linaria/react';
|
||||
import { Trans } from '@lingui/react/macro';
|
||||
import { type ChangeEvent, type ReactNode, useContext, useRef } from 'react';
|
||||
import {
|
||||
type ChangeEvent,
|
||||
type ReactNode,
|
||||
useContext,
|
||||
useId,
|
||||
useRef,
|
||||
} from 'react';
|
||||
import Skeleton, { SkeletonTheme } from 'react-loading-skeleton';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { Avatar, type AvatarType } from 'twenty-ui/data-display';
|
||||
@@ -9,7 +15,6 @@ import { type IconComponent } from 'twenty-ui/icon';
|
||||
import { AppTooltip } from 'twenty-ui/surfaces';
|
||||
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
|
||||
import { ThemeContext, themeCssVariables } from 'twenty-ui/theme-constants';
|
||||
import { v4 as uuidV4 } from 'uuid';
|
||||
import { dateLocaleState } from '~/localization/states/dateLocaleState';
|
||||
import {
|
||||
beautifyExactDateTime,
|
||||
@@ -125,7 +130,8 @@ export const ShowPageSummaryCard = ({
|
||||
const beautifiedCreatedAt =
|
||||
date !== '' ? beautifyPastDateRelativeToNow(date, localeCatalog) : '';
|
||||
const exactCreatedAt = date !== '' ? beautifyExactDateTime(date) : '';
|
||||
const dateElementId = `date-id-${uuidV4()}`;
|
||||
const instanceId = useId();
|
||||
const dateElementId = `date-id-${instanceId}`;
|
||||
const inputFileRef = useRef<HTMLInputElement>(null);
|
||||
const onFileChange = (e: ChangeEvent<HTMLInputElement>) => {
|
||||
if (isDefined(e.target.files)) onUploadPicture?.(e.target.files[0]);
|
||||
|
||||
Reference in New Issue
Block a user