@@ -4,6 +4,8 @@ import androidx.compose.foundation.Image
44import androidx.compose.foundation.background
55import androidx.compose.foundation.clickable
66import androidx.compose.foundation.gestures.detectTapGestures
7+ import androidx.compose.foundation.interaction.FocusInteraction
8+ import androidx.compose.foundation.interaction.MutableInteractionSource
79import androidx.compose.foundation.layout.Arrangement
810import androidx.compose.foundation.layout.Row
911import androidx.compose.foundation.layout.WindowInsets
@@ -21,6 +23,7 @@ import androidx.compose.foundation.layout.statusBars
2123import androidx.compose.foundation.layout.width
2224import androidx.compose.foundation.layout.windowInsetsPadding
2325import androidx.compose.foundation.lazy.LazyColumn
26+ import androidx.compose.material.ripple
2427import androidx.compose.runtime.Composable
2528import androidx.compose.runtime.LaunchedEffect
2629import androidx.compose.runtime.MutableState
@@ -112,6 +115,18 @@ fun SuperDropdown(
112115 var dropdownOffsetYPx by remember { mutableStateOf(0 ) }
113116 var componentHeightPx by remember { mutableStateOf(0 ) }
114117 var componentWidthPx by remember { mutableStateOf(0 ) }
118+ val interactionSource = remember { MutableInteractionSource () }
119+ val focus = remember { mutableStateOf<FocusInteraction .Focus ?>(null ) }
120+
121+ LaunchedEffect (isDropdownExpanded.value) {
122+ if (isDropdownExpanded.value) {
123+ focus.value = FocusInteraction .Focus ().also {
124+ interactionSource.emit(it)
125+ }
126+ } else {
127+ focus.value?.let { interactionSource.emit(FocusInteraction .Unfocus (it)) }
128+ }
129+ }
115130
116131 BasicComponent (
117132 modifier = modifier
@@ -134,6 +149,15 @@ fun SuperDropdown(
134149 componentHeightPx = coordinates.size.height
135150 componentWidthPx = coordinates.size.width
136151 }
152+ }
153+ .clickable(
154+ interactionSource = interactionSource,
155+ indication = ripple()
156+ ) {
157+ if (enabled) {
158+ isDropdownExpanded.value = enabled
159+ hapticFeedback.performHapticFeedback(HapticFeedbackType .LongPress )
160+ }
137161 },
138162 insideMargin = insideMargin,
139163 title = title,
@@ -157,12 +181,6 @@ fun SuperDropdown(
157181 contentDescription = null
158182 )
159183 },
160- onClick = {
161- if (enabled) {
162- isDropdownExpanded.value = enabled
163- hapticFeedback.performHapticFeedback(HapticFeedbackType .LongPress )
164- }
165- },
166184 enabled = enabled
167185 )
168186 if (isDropdownExpanded.value) {
0 commit comments