-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Avoid canvas tooltip unmount #38887
Conversation
WalkthroughThe pull request focuses on refactoring the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
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.
Actionable comments posted: 1
🧹 Nitpick comments (1)
app/client/src/pages/Editor/WidgetsEditor/components/CodeModeTooltip.tsx (1)
Line range hint
1-19
: Define explicit Props interface for better type safety.Consider adding an explicit interface for the component props:
interface CodeModeTooltipProps { children: React.ReactElement; }
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/client/src/pages/Editor/WidgetsEditor/components/CodeModeTooltip.tsx
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (8)
- GitHub Check: perform-test / rts-build / build
- GitHub Check: perform-test / server-build / server-unit-tests
- GitHub Check: perform-test / client-build / client-build
- GitHub Check: client-unit-tests / client-unit-tests
- GitHub Check: client-lint / client-lint
- GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
- GitHub Check: client-build / client-build
- GitHub Check: client-prettier / prettier-check
🔇 Additional comments (2)
app/client/src/pages/Editor/WidgetsEditor/components/CodeModeTooltip.tsx (2)
37-43
: Well-implemented memoization!Good use of useMemo with proper dependencies to optimize the disabled state computation.
Line range hint
45-54
: Clean tooltip implementation.The use of memoized isDisabled prop effectively prevents unnecessary remounts, which aligns well with the PR objectives.
useEffect( | ||
function handleMaxTimesTooltipShown() { | ||
retrieveCodeWidgetNavigationUsed() | ||
.then((timesUsed) => { | ||
if (timesUsed < 2) { | ||
setShouldShow(true); | ||
} | ||
}) | ||
.catch(() => { | ||
setShouldShow(true); | ||
} | ||
}) | ||
.catch(() => { | ||
setShouldShow(true); | ||
}); | ||
}, [isWidgetSelectionBlock]); | ||
|
||
if (!isWidgetSelectionBlock) return props.children; | ||
}); | ||
}, | ||
[isWidgetSelectionBlock], | ||
); |
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.
Improve error handling in useEffect.
The error case unconditionally sets shouldShow
to true, which might display the tooltip unnecessarily. Consider maintaining the same logic as the success case.
.catch(() => {
- setShouldShow(true);
+ // Either handle the error silently or log it
+ console.error('Failed to retrieve code widget navigation count');
});
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
useEffect( | |
function handleMaxTimesTooltipShown() { | |
retrieveCodeWidgetNavigationUsed() | |
.then((timesUsed) => { | |
if (timesUsed < 2) { | |
setShouldShow(true); | |
} | |
}) | |
.catch(() => { | |
setShouldShow(true); | |
} | |
}) | |
.catch(() => { | |
setShouldShow(true); | |
}); | |
}, [isWidgetSelectionBlock]); | |
if (!isWidgetSelectionBlock) return props.children; | |
}); | |
}, | |
[isWidgetSelectionBlock], | |
); | |
useEffect( | |
function handleMaxTimesTooltipShown() { | |
retrieveCodeWidgetNavigationUsed() | |
.then((timesUsed) => { | |
if (timesUsed < 2) { | |
setShouldShow(true); | |
} | |
}) | |
.catch(() => { | |
// Either handle the error silently or log it | |
console.error('Failed to retrieve code widget navigation count'); | |
}); | |
}, | |
[isWidgetSelectionBlock], | |
); |
Description
Instead of updating the component layer when choosing to show the tooltip on canvas view mode, we would instead just mark the tooltip disabled when no required. This makes sure the children are not remounted based on conditions in the tooltip component
Fixes #38886
Automation
/ok-to-test tags="@tag.IDE"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13026069462
Commit: a593a65
Cypress dashboard.
Tags:
@tag.IDE
Spec:
Wed, 29 Jan 2025 07:22:50 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit
CodeModeTooltip
componentuseMemo
hook