-
Notifications
You must be signed in to change notification settings - Fork 34
[TEMPURA-3464] Added optional onClick lambda to Close Button in bottom sheet #2530
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
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 adds an optional onClick callback parameter to the close button of the bottom sheet modal component. The onClick callback executes before the dismiss request when users tap the close button, enabling additional actions like logging or state updates during the closing process.
Key Changes:
- Added optional
onClicklambda parameter toBpkModalBottomSheetCloseAction.Close - Integrated the callback invocation in the close button's click handler
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| BpkModalBottomSheet.kt | Added optional onClick parameter to BpkModalBottomSheetCloseAction.Close data class |
| BpkModalBottomSheetImpl.kt | Invokes the optional onClick callback when close button is clicked, before dismissing |
| closeButton.onClick?.invoke() | ||
| onDismissRequest() |
Copilot
AI
Dec 17, 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 onClick callback is invoked after the hide animation completes via invokeOnCompletion. This may cause unexpected behavior if consumers expect their callback to execute before the sheet starts hiding. Consider invoking closeButton.onClick?.invoke() before coroutineScope.launch { state.hide() } to ensure the callback executes immediately when the button is clicked.
| data object None : BpkModalBottomSheetCloseAction() | ||
| data class Close( | ||
| val contentDescription: String, | ||
| val onClick: (() -> Unit)? = null, |
Copilot
AI
Dec 17, 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 onClick parameter lacks documentation explaining when it is invoked relative to onDismissRequest and the sheet's hide animation. Add a KDoc comment explaining that this callback is invoked during the close button click handling and describing its relationship to the dismiss behavior.
| data object None : BpkModalBottomSheetCloseAction() | ||
| data class Close( | ||
| val contentDescription: String, | ||
| val onClick: (() -> Unit)? = null, |
Copilot
AI
Dec 17, 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 new onClick callback parameter lacks test coverage. Add tests to verify that the callback is invoked when the close button is clicked, and that onDismissRequest is still called regardless of whether onClick is provided.
Generated by 🚫 Danger Kotlin against 0062cf5 |
Generated by 🚫 Danger Kotlin against 538b44b |
An optional lambda has been added to
BpkModalBottomSheetCloseAction.Close. Overriding this does not disableonDismissRequest(). I.e, clicking the close button will invoke this optional lambda if it is not null, and then invokeonDismissRequest().Remember to include the following changes:
README.mdIf you are curious about how we review, please read through the code review guidelines