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 Keyboard disappears on IME action #1118

Merged
merged 5 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
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
@@ -0,0 +1,73 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package androidx.compose.mpp.demo.bug

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material.Button
import androidx.compose.material.OutlinedTextField
import androidx.compose.material.Text
import androidx.compose.material3.MaterialTheme
import androidx.compose.mpp.demo.Screen
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.KeyboardType
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog

val KeyboardIMEActionPopup = Screen.Example("KeyboardIMEActionPopup") {
Column {
var visible by remember { mutableStateOf(false) }

Spacer(modifier = Modifier.height(32.dp))
OutlinedTextField(
value = "",
onValueChange = {},
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Text,
imeAction = ImeAction.Done
)
)
Spacer(modifier = Modifier.height(32.dp))
Button(
onClick = { visible = true }
) {
Text("Expand")
}

if (visible)
Dialog(
onDismissRequest = { visible = false }
) {
Box(
modifier = Modifier
.fillMaxWidth()
.height(150.dp)
.background(MaterialTheme.colorScheme.primary)
)
}
}
}
2 changes: 2 additions & 0 deletions compose/mpp/demo/src/uikitMain/kotlin/bugs/IosBugs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package bugs
import androidx.compose.mpp.demo.Screen
import androidx.compose.mpp.demo.bug.BackspaceIssue
import androidx.compose.mpp.demo.bug.DropdownMenuIssue
import androidx.compose.mpp.demo.bug.KeyboardIMEActionPopup

val IosBugs = Screen.Selection(
"IosBugs",
Expand All @@ -31,4 +32,5 @@ val IosBugs = Screen.Selection(
StartRecompositionCheck,
BackspaceIssue,
DropdownMenuIssue,
KeyboardIMEActionPopup,
)
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ internal class FocusStackImpl : FocusStack<UIView> {
override fun popUntilNext(view: UIView) {
if (activeViews.contains(view)) {
val index = activeViews.indexOf(view)
resignedViews += activeViews.subList(index, activeViews.lastIndex)
resignedViews += activeViews.subList(index, activeViews.size)
activeViews = activeViews.subList(0, index)

mainScope.launch {
Expand Down
Loading