-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
fix: Prevent Tooltip setState call if not open #5363
Conversation
Deploy preview for carbon-elements ready! Built with commit 187df6e |
Deploy preview for carbon-components-react ready! Built with commit 187df6e https://deploy-preview-5363--carbon-components-react.netlify.com |
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.
LGTM 🎉
@asudoh it looks like this is for tooltip rather than overflow menu and should be a port of carbon-design-system/carbon-components-react#2424 right? |
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.
looks good to me
@grommett My apologies for confusing this one with the other! |
This PR prevents the
handleClickOutside
from callingsetState
if the ToolTip is already closed. This same code change was merged in the previous version of Carbon React.The reason for this check is that, at scale, these calls create real performance issues.
Our app has over 1,000
<Tooltip />
s. Each of these<Tooltip />
s callssetState({open: false})
for any click in the UI. The unnecessary calls tosetState
makes toggling radio buttons and opening Modals very, very slow. Up to two seconds in some cases in our UI. After adding this check the UI behaves normally.Changelog
Changed
handleClickOutside
method.Testing / Reviewing
Below is a performance screenshot with current behavior.