Skip to content
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

add access to dismiss callback in dropdown inputs #335

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ private const val MAX_DROPDOWN_ITEMS_TO_SHOW = 50
* @param showSearchBar: config whether to show search bar in the bottom sheet.
* @param expanded: config whether the dropdown should be initially displayed.
* @param useDropDown: use dropdown if true. Bottomsheet with search capability otherwise.
* @param onDismiss: gives access to the onDismiss event.
* @param noResultsFoundString: text to be shown in pop up when no results are found.
*/
@OptIn(ExperimentalMaterial3Api::class)
Expand All @@ -98,6 +99,7 @@ fun InputDropDown(
expanded: Boolean = false,
useDropDown: Boolean = true,
loadOptions: () -> Unit,
onDismiss: () -> Unit = {},
noResultsFoundString: String = provideStringResource("no_results_found"),
searchToFindMoreString: String = provideStringResource("search_to_see_more"),
) {
Expand Down Expand Up @@ -160,6 +162,7 @@ fun InputDropDown(
currentItem = this
onItemSelected(index, this)
showDropdown = false
onDismiss()
},
)
}
Expand Down Expand Up @@ -187,6 +190,7 @@ fun InputDropDown(
},
onDismiss = {
showDropdown = false
onDismiss()
},
searchQuery = if (showSearchBar) {
searchQuery
Expand Down Expand Up @@ -221,7 +225,10 @@ fun InputDropDown(
) {
ExposedDropdownMenu(
expanded = showDropdown,
onDismissRequest = { showDropdown = false },
onDismissRequest = {
showDropdown = false
onDismiss()
},
modifier = Modifier.background(
color = SurfaceColor.SurfaceBright,
shape = RoundedCornerShape(Spacing8),
Expand All @@ -243,6 +250,7 @@ fun InputDropDown(
currentItem = this
onItemSelected(index, this)
showDropdown = false
onDismiss()
},
)
}
Expand Down
Loading