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

Fix delete on empty move to previous. #4706

Merged
merged 1 commit into from
Mar 15, 2022
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 @@ -22,7 +22,7 @@ import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.onFocusChanged
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.key.KeyEventType
import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.key.onPreviewKeyEvent
import androidx.compose.ui.input.key.type
import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.res.painterResource
Expand Down Expand Up @@ -112,14 +112,16 @@ internal fun TextField(
},
modifier = modifier
.fillMaxWidth()
.onKeyEvent { event ->
if (event.type == KeyEventType.KeyUp &&
.onPreviewKeyEvent { event ->
if (event.type == KeyEventType.KeyDown &&
event.nativeKeyEvent.keyCode == KeyEvent.KEYCODE_DEL &&
value.isEmpty()
) {
focusManager.moveFocus(FocusDirection.Previous)
true
} else {
false
}
false
}
.onFocusChanged {
if (hasFocus != it.isFocused) {
Expand Down