-
Notifications
You must be signed in to change notification settings - Fork 6
fix(ItemBase): size observer #770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
🦋 Changeset detectedLatest commit: 3206da9 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📦 NPM canary releaseDeployed canary version 0.0.0-canary-1d46daa. |
🧪 Storybook is successfully deployed!
|
🏋️ Size limit report
Click here if you want to find out what is changed in this build |
There was a problem hiding this 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]); |
Copilot
AI
Aug 27, 2025
There was a problem hiding this comment.
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.
| }, [mergedLabelRef.current]); | |
| }, [mergedLabelRef]); |
| if (isAutoTooltipEnabled) { | ||
| checkLabelOverflow(); | ||
| } | ||
| }, [children, isAutoTooltipEnabled]); |
Copilot
AI
Aug 27, 2025
There was a problem hiding this comment.
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.
| }, [children, isAutoTooltipEnabled]); | |
| }, [children, isAutoTooltipEnabled, checkLabelOverflow]); |
|
|
||
| // return () => resizeObserver.disconnect(); | ||
| return () => resizeObserver.disconnect(); | ||
| }, [mergedLabelRef.current, isAutoTooltipEnabled]); |
Copilot
AI
Aug 27, 2025
There was a problem hiding this comment.
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.
| }, [mergedLabelRef.current, isAutoTooltipEnabled]); | |
| }, [mergedLabelRef, isAutoTooltipEnabled, checkLabelOverflow]); |
| }, [children, isAutoTooltipEnabled, checkLabelOverflow]); | ||
|
|
||
| useLayoutEffect(() => { | ||
| useEffect(() => { |
There was a problem hiding this comment.
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.
No description provided.