Skip to content

Conversation

@tenphi
Copy link
Member

@tenphi tenphi commented Aug 27, 2025

No description provided.

@changeset-bot
Copy link

changeset-bot bot commented Aug 27, 2025

🦋 Changeset detected

Latest commit: 3206da9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@cube-dev/ui-kit Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 27, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
cube-ui-kit Ready Ready Preview Comment Aug 27, 2025 4:11pm
cube-ui-kit-cursor Ready Ready Preview Comment Aug 27, 2025 4:11pm

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2025

📦 NPM canary release

Deployed canary version 0.0.0-canary-1d46daa.

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2025

🧪 Storybook is successfully deployed!

@github-actions
Copy link
Contributor

github-actions bot commented Aug 27, 2025

🏋️ Size limit report

Name Size Passed?
All 287.05 KB (+0.01% 🔺) Yes 🎉
Tree shaking (just a Button) 24.42 KB (0% 🟰) Yes 🎉
Tree shaking (just an Icon) 12.2 KB (0% 🟰) Yes 🎉

Click here if you want to find out what is changed in this build

cursor[bot]

This comment was marked as outdated.

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the size observer functionality in the ItemBase component by properly implementing ResizeObserver to detect label overflow. The change enables automatic tooltip functionality when text content overflows its container.

  • Uncommented and properly integrated ResizeObserver for monitoring label size changes
  • Converted overflow check function to useCallback for performance optimization
  • Updated useLayoutEffect to useEffect for the observer setup

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/components/content/ItemBase/ItemBase.tsx Implements ResizeObserver to monitor label overflow and optimizes callback memoization
.changeset/silver-laws-flash.md Documents the addition of size observer functionality

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


setIsLabelOverflowed(hasOverflow);
};
}, [mergedLabelRef.current]);
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The dependency mergedLabelRef.current will not trigger re-renders when it changes since React doesn't track changes to .current properties. This should be [mergedLabelRef] or consider using a different approach to track label changes.

Suggested change
}, [mergedLabelRef.current]);
}, [mergedLabelRef]);

Copilot uses AI. Check for mistakes.
if (isAutoTooltipEnabled) {
checkLabelOverflow();
}
}, [children, isAutoTooltipEnabled]);
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The useEffect dependencies are missing checkLabelOverflow. This could lead to stale closure issues where an outdated version of the function is called.

Suggested change
}, [children, isAutoTooltipEnabled]);
}, [children, isAutoTooltipEnabled, checkLabelOverflow]);

Copilot uses AI. Check for mistakes.

// return () => resizeObserver.disconnect();
return () => resizeObserver.disconnect();
}, [mergedLabelRef.current, isAutoTooltipEnabled]);
Copy link

Copilot AI Aug 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to line 512, mergedLabelRef.current will not trigger re-renders when it changes. The dependency should be mergedLabelRef instead, and checkLabelOverflow should also be included in the dependencies.

Suggested change
}, [mergedLabelRef.current, isAutoTooltipEnabled]);
}, [mergedLabelRef, isAutoTooltipEnabled, checkLabelOverflow]);

Copilot uses AI. Check for mistakes.
}, [children, isAutoTooltipEnabled, checkLabelOverflow]);

useLayoutEffect(() => {
useEffect(() => {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Async Effect Timing Causes Tooltip Flicker

The switch from useLayoutEffect to useEffect for DOM measurements and ResizeObserver setup can cause visual flicker and incorrect auto-tooltip behavior. useEffect runs asynchronously after paint, leading to label overflow measurements being taken at the wrong time.

Fix in Cursor Fix in Web

@tenphi tenphi merged commit 2133671 into main Aug 27, 2025
14 checks passed
@tenphi tenphi deleted the fix-itembase-observer branch August 27, 2025 16:11
@github-actions github-actions bot mentioned this pull request Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants