Pressing esc closes (un)commited changes filter
This commit is contained in:
parent
9dfd5073bd
commit
3ee8163e2d
@ -160,6 +160,7 @@ fun CommitChangesView(
|
||||
searchFilter = searchFilter,
|
||||
onSearchFilterChanged = onSearchFilterChanged,
|
||||
searchFocusRequester = searchFocusRequester,
|
||||
onClose = { onSearchFilterToggled(false) },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -663,6 +663,7 @@ private fun EntriesList(
|
||||
searchFilter = searchFilter,
|
||||
onSearchFilterChanged = onSearchFilterChanged,
|
||||
searchFocusRequester = searchFocusRequester,
|
||||
onClose = { onSearchFilterToggled(false) },
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -10,19 +10,32 @@ import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.focus.FocusRequester
|
||||
import androidx.compose.ui.focus.focusRequester
|
||||
import androidx.compose.ui.input.key.KeyEventType
|
||||
import androidx.compose.ui.input.key.onPreviewKeyEvent
|
||||
import androidx.compose.ui.input.key.type
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.jetpackduba.gitnuro.keybindings.KeybindingOption
|
||||
import com.jetpackduba.gitnuro.keybindings.matchesBinding
|
||||
|
||||
@Composable
|
||||
fun SearchTextField(
|
||||
searchFilter: TextFieldValue,
|
||||
onSearchFilterChanged: (TextFieldValue) -> Unit,
|
||||
searchFocusRequester: FocusRequester,
|
||||
onClose: () -> Unit,
|
||||
) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colors.background)
|
||||
.padding(horizontal = 4.dp, vertical = 4.dp)
|
||||
.onPreviewKeyEvent { keyEvent ->
|
||||
if (keyEvent.matchesBinding(KeybindingOption.EXIT) && keyEvent.type == KeyEventType.KeyDown) {
|
||||
onClose()
|
||||
true
|
||||
} else
|
||||
false
|
||||
},
|
||||
) {
|
||||
AdjustableOutlinedTextField(
|
||||
value = searchFilter,
|
||||
|
Loading…
Reference in New Issue
Block a user