-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: trigger context.onClose when closing the confirmation exit modal #244
base: main
Are you sure you want to change the base?
Conversation
WalkthroughThe pull request introduces a modification to the Changes
Sequence DiagramsequenceDiagram
participant User
participant EmbeddedIFrameWrapper
participant ConfirmCloseModal
participant OnCloseHandler
User->>EmbeddedIFrameWrapper: Trigger Close
EmbeddedIFrameWrapper->>ConfirmCloseModal: Open Close Confirmation
User->>ConfirmCloseModal: Confirm Close
ConfirmCloseModal->>ConfirmCloseModal: handleCloseInstance()
ConfirmCloseModal->>OnCloseHandler: Conditionally invoke onClose.current()
The sequence diagram illustrates the new flow where closing the component involves a confirmation modal and an optional 🪧 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
CodeRabbit Configuration File (
|
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: 0
🧹 Nitpick comments (1)
packages/react/src/components/EmbeddedIFrameWrapper.tsx (1)
99-104
: Consider refactoring the nested conditions.The nested conditions make the code harder to read and maintain. Consider extracting the cleanup logic into a separate function.
- onConfirm={() => { - handleCloseInstance() - setShowExitWarnModal(false) - if (closeSpace && typeof closeSpace.onClose === 'function') { - closeSpace.onClose({}) - onClose.current?.() - } - }} + onConfirm={() => { + const cleanup = () => { + handleCloseInstance() + setShowExitWarnModal(false) + } + cleanup() + if (closeSpace?.onClose && typeof closeSpace.onClose === 'function') { + closeSpace.onClose({}) + onClose.current?.() + } + }}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/react/src/components/EmbeddedIFrameWrapper.tsx
(2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Lint
- GitHub Check: Test
🔇 Additional comments (1)
packages/react/src/components/EmbeddedIFrameWrapper.tsx (1)
21-21
: Verify the type definition ofonClose
inFlatfileContext
.The addition of
onClose
to the context looks good. However, let's verify its type definition.✅ Verification successful
Type definition and implementation of
onClose
is correctThe
onClose
property inFlatfileContext
is properly typed asMutableRefObject<null | undefined | (() => void)>
and its implementation follows React's best practices for handling callbacks through refs.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the type definition of `onClose` in FlatfileContext. # Test: Search for the type definition of `onClose` in FlatfileContext. ast-grep --pattern $'interface FlatfileContext { $$$ onClose: $_ $$$ }' # Test: Search for any other references to `onClose` in the codebase. rg -A 5 $'onClose'Length of output: 19345
Please explain how to summarize this PR for the Changelog:
Tell code reviewer how and what to test: