Clear focus when submitting forms to prevent issues with the IME keyboard. (#139)
This commit is contained in:
parent
abec09908a
commit
811cca6289
3 changed files with 21 additions and 4 deletions
1
changelog.d/133.bugfix
Normal file
1
changelog.d/133.bugfix
Normal file
|
|
@ -0,0 +1 @@
|
|||
Clear focus on TextFields when submitting forms to prevent issues with the IME keyboard.
|
||||
|
|
@ -92,6 +92,14 @@ fun ChangeServerView(
|
|||
}
|
||||
}
|
||||
val focusManager = LocalFocusManager.current
|
||||
|
||||
fun submit() {
|
||||
// Clear focus to prevent keyboard issues with textfields
|
||||
focusManager.clearFocus(force = true)
|
||||
|
||||
eventSink(ChangeServerEvents.Submit)
|
||||
}
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
|
|
@ -175,7 +183,7 @@ fun ChangeServerView(
|
|||
imeAction = ImeAction.Done,
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { eventSink(ChangeServerEvents.Submit) }
|
||||
onDone = { submit() }
|
||||
),
|
||||
singleLine = true,
|
||||
maxLines = 1,
|
||||
|
|
@ -216,7 +224,7 @@ fun ChangeServerView(
|
|||
)
|
||||
Spacer(Modifier.height(32.dp))
|
||||
Button(
|
||||
onClick = { eventSink(ChangeServerEvents.Submit) },
|
||||
onClick = ::submit,
|
||||
enabled = interactionEnabled && state.submitEnabled,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
|||
|
|
@ -223,6 +223,14 @@ internal fun LoginForm(
|
|||
|
||||
val focusManager = LocalFocusManager.current
|
||||
val eventSink = state.eventSink
|
||||
|
||||
fun submit() {
|
||||
// Clear focus to prevent keyboard issues with textfields
|
||||
focusManager.clearFocus(force = true)
|
||||
|
||||
eventSink(LoginRootEvents.Submit)
|
||||
}
|
||||
|
||||
Column(modifier) {
|
||||
Text(
|
||||
text = stringResource(StringR.string.login_form_title),
|
||||
|
|
@ -301,7 +309,7 @@ internal fun LoginForm(
|
|||
imeAction = ImeAction.Done,
|
||||
),
|
||||
keyboardActions = KeyboardActions(
|
||||
onDone = { eventSink(LoginRootEvents.Submit) }
|
||||
onDone = { submit() }
|
||||
),
|
||||
singleLine = true,
|
||||
maxLines = 1,
|
||||
|
|
@ -310,7 +318,7 @@ internal fun LoginForm(
|
|||
|
||||
// Submit
|
||||
Button(
|
||||
onClick = { eventSink(LoginRootEvents.Submit) },
|
||||
onClick = ::submit,
|
||||
enabled = interactionEnabled && state.submitEnabled,
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue