Skip to content

Commit

Permalink
reproduce and reminder about iOS SelectionContainer bug (#867)
Browse files Browse the repository at this point in the history
Made reproducer of a bug
JetBrains/compose-multiplatform#3718
This bug should be fixed after merging newer version of androidx-main to
jb-main branch.
Added TODO comment to check and close related issues after that.
  • Loading branch information
dima-avdeev-jb authored and mazunin-v-jb committed Dec 7, 2023
1 parent 23ad1fc commit 8d1e0f0
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.compose.foundation.lazy.items
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowBack
import androidx.compose.mpp.demo.bug.BugReproducers
import androidx.compose.mpp.demo.components.Components
import androidx.compose.mpp.demo.textfield.android.AndroidTextFieldSamples
import androidx.compose.runtime.Composable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright 2023 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.mpp.demo.Screen

val BugReproducers = Screen.Selection(
"Bug Reproducers",
NoRecompositionInLazyGrid,
RoundedCornerCrashOnJS,
CodeViewerReproducer,
SelectionContainerCrash,
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,20 @@
* limitations under the License.
*/

package androidx.compose.mpp.demo
package androidx.compose.mpp.demo.bug

import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Text
import androidx.compose.runtime.Composable

import androidx.compose.mpp.demo.Screen

// https://github.com/JetBrains/compose-multiplatform/issues/3560
@Composable
fun CodeViewerReproducer() {
val CodeViewerReproducer = Screen.Example("CodeViewerReproducer") {
SelectionContainer {
LazyColumn {
items(100) {
Text(text = "Text $it",)
Text(text = "Text $it")
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

package androidx.compose.mpp.demo
package androidx.compose.mpp.demo.bug

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxWithConstraints
Expand All @@ -25,18 +25,16 @@ import androidx.compose.foundation.lazy.grid.LazyVerticalGrid
import androidx.compose.foundation.lazy.grid.itemsIndexed
import androidx.compose.material.Text
import androidx.compose.material.TextField
import androidx.compose.runtime.*
import androidx.compose.mpp.demo.Screen
import androidx.compose.runtime.derivedStateOf
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

val BugReproducers = Screen.Selection("Bug Reproducers",
// https://github.com/JetBrains/compose-multiplatform/issues/3475
Screen.Example("No Recomposition in Lazy Grid") { NoRecompositionInLazyGrid() },
Screen.Example("RoundedCornerCrashOnJS") { RoundedCornerCrashOnJS() },
Screen.Example("Code Viewer - Selection Reproducer") { CodeViewerReproducer() },
)

@Composable
fun NoRecompositionInLazyGrid() {
// https://github.com/JetBrains/compose-multiplatform/issues/3475
val NoRecompositionInLazyGrid = Screen.Example("No Recomposition in Lazy Grid") {
var string by remember { mutableStateOf("1") }
val value by derivedStateOf {
maxOf(string.toIntOrNull() ?: 1, 1)
Expand All @@ -54,11 +52,11 @@ fun NoRecompositionInLazyGrid() {
columns = GridCells.Fixed(value),
modifier = Modifier.fillMaxSize()
) {
itemsIndexed(gridItems) { index, _->
itemsIndexed(gridItems) { index, _ ->
Text("Item index: $index")
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
* limitations under the License.
*/

package androidx.compose.mpp.demo
package androidx.compose.mpp.demo.bug

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.runtime.Composable
import androidx.compose.mpp.demo.Screen
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.graphicsLayer
import androidx.compose.ui.unit.dp

@Composable
fun RoundedCornerCrashOnJS() {
val RoundedCornerCrashOnJS = Screen.Example("RoundedCornerCrashOnJS") {
// Crash happens in ShadowUtils.drawShadow(
// Related issue https://github.com/JetBrains/compose-multiplatform/issues/3013
Box(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 2023 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.layout.Column
import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material.Text
import androidx.compose.mpp.demo.Screen

val SelectionContainerCrash = Screen.Example("SelectionContainerCrash") {
//TODO: This bug is already fixed in latest androidx-main branch.
// Related CL: https://android-review.googlesource.com/c/platform/frameworks/support/+/2616177/3/compose/foundation/foundation/src/commonMain/kotlin/androidx/compose/foundation/text/selection/SelectionAdjustment.kt
// Check and close this bug after merging androidx-main on jb-main branch.
// https://youtrack.jetbrains.com/issue/COMPOSE-478/fix-iOS-SelectionContainer
// https://github.com/JetBrains/compose-multiplatform/issues/3718
SelectionContainer {
Column {
Text("aaa")
Text("")
Text("bbb")
}
}
}

0 comments on commit 8d1e0f0

Please sign in to comment.