Clear focus when submitting forms to prevent issues with the IME keyboard. (#139)
This commit is contained in:
parent
c718c9b737
commit
0c8d8b62f8
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
|
val focusManager = LocalFocusManager.current
|
||||||
|
|
||||||
|
fun submit() {
|
||||||
|
// Clear focus to prevent keyboard issues with textfields
|
||||||
|
focusManager.clearFocus(force = true)
|
||||||
|
|
||||||
|
eventSink(ChangeServerEvents.Submit)
|
||||||
|
}
|
||||||
|
|
||||||
Scaffold(
|
Scaffold(
|
||||||
topBar = {
|
topBar = {
|
||||||
TopAppBar(
|
TopAppBar(
|
||||||
|
|
@ -175,7 +183,7 @@ fun ChangeServerView(
|
||||||
imeAction = ImeAction.Done,
|
imeAction = ImeAction.Done,
|
||||||
),
|
),
|
||||||
keyboardActions = KeyboardActions(
|
keyboardActions = KeyboardActions(
|
||||||
onDone = { eventSink(ChangeServerEvents.Submit) }
|
onDone = { submit() }
|
||||||
),
|
),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
|
@ -216,7 +224,7 @@ fun ChangeServerView(
|
||||||
)
|
)
|
||||||
Spacer(Modifier.height(32.dp))
|
Spacer(Modifier.height(32.dp))
|
||||||
Button(
|
Button(
|
||||||
onClick = { eventSink(ChangeServerEvents.Submit) },
|
onClick = ::submit,
|
||||||
enabled = interactionEnabled && state.submitEnabled,
|
enabled = interactionEnabled && state.submitEnabled,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
|
||||||
|
|
@ -223,6 +223,14 @@ internal fun LoginForm(
|
||||||
|
|
||||||
val focusManager = LocalFocusManager.current
|
val focusManager = LocalFocusManager.current
|
||||||
val eventSink = state.eventSink
|
val eventSink = state.eventSink
|
||||||
|
|
||||||
|
fun submit() {
|
||||||
|
// Clear focus to prevent keyboard issues with textfields
|
||||||
|
focusManager.clearFocus(force = true)
|
||||||
|
|
||||||
|
eventSink(LoginRootEvents.Submit)
|
||||||
|
}
|
||||||
|
|
||||||
Column(modifier) {
|
Column(modifier) {
|
||||||
Text(
|
Text(
|
||||||
text = stringResource(StringR.string.login_form_title),
|
text = stringResource(StringR.string.login_form_title),
|
||||||
|
|
@ -301,7 +309,7 @@ internal fun LoginForm(
|
||||||
imeAction = ImeAction.Done,
|
imeAction = ImeAction.Done,
|
||||||
),
|
),
|
||||||
keyboardActions = KeyboardActions(
|
keyboardActions = KeyboardActions(
|
||||||
onDone = { eventSink(LoginRootEvents.Submit) }
|
onDone = { submit() }
|
||||||
),
|
),
|
||||||
singleLine = true,
|
singleLine = true,
|
||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
|
|
@ -310,7 +318,7 @@ internal fun LoginForm(
|
||||||
|
|
||||||
// Submit
|
// Submit
|
||||||
Button(
|
Button(
|
||||||
onClick = { eventSink(LoginRootEvents.Submit) },
|
onClick = ::submit,
|
||||||
enabled = interactionEnabled && state.submitEnabled,
|
enabled = interactionEnabled && state.submitEnabled,
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.fillMaxWidth()
|
.fillMaxWidth()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue