Fix behaviour of Enter and Tab hardware keys in TextFields (#216)
* Fix behaviour of Enter and Tab hardware keys in TextFields * Add changelog
This commit is contained in:
parent
3fb87c40fd
commit
ce981bc6a5
3 changed files with 9 additions and 6 deletions
1
changelog.d/216.bugfix
Normal file
1
changelog.d/216.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Make sure `Modifier.onTabOrEnterKeyFocusNext` doesn't add line breaks or tabs to TextFields.
|
||||||
|
|
@ -244,8 +244,8 @@ internal fun LoginForm(
|
||||||
readOnly = !interactionEnabled,
|
readOnly = !interactionEnabled,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.testTag(TestTags.loginEmailUsername)
|
.onTabOrEnterKeyFocusNext(focusManager)
|
||||||
.onTabOrEnterKeyFocusNext(focusManager),
|
.testTag(TestTags.loginEmailUsername),
|
||||||
label = {
|
label = {
|
||||||
Text(text = stringResource(StringR.string.ex_login_username_hint))
|
Text(text = stringResource(StringR.string.ex_login_username_hint))
|
||||||
},
|
},
|
||||||
|
|
@ -284,8 +284,8 @@ internal fun LoginForm(
|
||||||
readOnly = !interactionEnabled,
|
readOnly = !interactionEnabled,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
.testTag(TestTags.loginPassword)
|
.onTabOrEnterKeyFocusNext(focusManager)
|
||||||
.onTabOrEnterKeyFocusNext(focusManager),
|
.testTag(TestTags.loginPassword),
|
||||||
onValueChange = {
|
onValueChange = {
|
||||||
passwordFieldState = it
|
passwordFieldState = it
|
||||||
eventSink(LoginRootEvents.SetPassword(it))
|
eventSink(LoginRootEvents.SetPassword(it))
|
||||||
|
|
|
||||||
|
|
@ -99,8 +99,10 @@ fun OutlinedTextField(
|
||||||
|
|
||||||
@OptIn(ExperimentalComposeUiApi::class)
|
@OptIn(ExperimentalComposeUiApi::class)
|
||||||
fun Modifier.onTabOrEnterKeyFocusNext(focusManager: FocusManager): Modifier = onPreviewKeyEvent { event ->
|
fun Modifier.onTabOrEnterKeyFocusNext(focusManager: FocusManager): Modifier = onPreviewKeyEvent { event ->
|
||||||
if (event.type == KeyEventType.KeyUp && (event.key == Key.Tab || event.key == Key.Enter)) {
|
if (event.key == Key.Tab || event.key == Key.Enter) {
|
||||||
focusManager.moveFocus(FocusDirection.Down)
|
if (event.type == KeyEventType.KeyUp) {
|
||||||
|
focusManager.moveFocus(FocusDirection.Down)
|
||||||
|
}
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue