Skip to content

Commit 01f8fec

Browse files
committed
Implemented filter clear in recent repositories when pressing escape
1 parent f82164d commit 01f8fec

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

src/main/kotlin/com/jetpackduba/gitnuro/ui/WelcomePage.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import androidx.compose.ui.graphics.Color
2626
import androidx.compose.ui.graphics.ColorFilter
2727
import androidx.compose.ui.graphics.painter.Painter
2828
import androidx.compose.ui.input.key.KeyEventType
29+
import androidx.compose.ui.input.key.onKeyEvent
2930
import androidx.compose.ui.input.key.onPreviewKeyEvent
3031
import androidx.compose.ui.input.key.type
3132
import androidx.compose.ui.text.font.FontWeight
@@ -381,7 +382,14 @@ fun RecentRepositoriesList(
381382
AdjustableOutlinedTextField(
382383
modifier = Modifier
383384
.focusRequester(searchFieldFocusRequester)
384-
.onFocusChanged { isSearchFocused = it.isFocused },
385+
.onFocusChanged { isSearchFocused = it.isFocused }
386+
.onPreviewKeyEvent { keyEvent ->
387+
if (keyEvent.matchesBinding(KeybindingOption.EXIT) && keyEvent.type == KeyEventType.KeyDown) {
388+
filter = ""
389+
true
390+
} else
391+
false
392+
},
385393
value = filter,
386394
onValueChange = { filter = it },
387395
singleLine = true,

0 commit comments

Comments
 (0)