Skip to content

Commit

Permalink
Fix keyboard disappear on IME action (#1118)
Browse files Browse the repository at this point in the history
## Proposed Changes

  - Fix for Issue when keyboard doesn't disappears on IME action
Where was mistake in indices. Because subList have arguments [exclusive,
inclusive)

## Testing

Added reproducer to Demo iOS app: IosBugs / KeyboardIMEActionPopup

## Issues Fixed
 - JetBrains/compose-multiplatform#4291

---------

Co-authored-by: Ivan Matkov <ivan.matkov@jetbrains.com>
  • Loading branch information
2 people authored and igordmn committed Feb 19, 2024
1 parent c22ebd3 commit ea72130
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
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

0 comments on commit ea72130

Please sign in to comment.