compose-multiplatform icon indicating copy to clipboard operation
compose-multiplatform copied to clipboard

Rendering a composable above the window causes a crash after changing the window size.

Open luludevmuniz opened this issue 1 year ago • 2 comments

Describe the bug After changing the browser window size, if some composable that renders above the window, it causes the application to crash.

Affected platforms

  • Web (K/Wasm) - Canvas based API

Versions

  • Kotlin version*: 1.9.21
  • Compose Multiplatform version*: 1.6.0-beta02

To Reproduce

  1. Go to kmp.jetbrains.com
  2. Selected Wasm option
  3. Download the project
  4. Replace the App() function for the codesnippet below
  5. Run the app in your browser
  6. Resize the browser screen size and click in the field to open the menu

Code Snippet:

import androidx.compose.foundation.layout.*
import androidx.compose.material.*
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.ArrowDropDown
import androidx.compose.runtime.*
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalMaterialApi::class)
@Composable
fun App() {
    MaterialTheme {
        var expanded by remember { mutableStateOf(false) }
        val items = listOf("1", "2")
        var selectedOptionText by remember { mutableStateOf(items[0]) }
        ExposedDropdownMenuBox(
            expanded = expanded,
            onExpandedChange = {
                expanded = it
            },
        ) {
            OutlinedTextField(
                modifier = Modifier
                    .fillMaxWidth()
                    .padding(top = 16.dp),
                value = selectedOptionText,
                onValueChange = {},
                readOnly = true
            )
            ExposedDropdownMenu(
                expanded = expanded,
                onDismissRequest = {
                    expanded = false
                },
            ) {
                items.forEach { selectionOption ->
                    DropdownMenuItem(
                        onClick = {
                            selectedOptionText = selectionOption
                            expanded = false
                        },
                    ) {
                        Text(selectionOption)

                    }
                }
            }
        }
    }
}

Error: Cannot coerce value to an empty range: maximum -1470 is less than minimum 0.

Expected behavior Don't crash the app and show the menu according

Screenshots https://github.com/JetBrains/compose-multiplatform/assets/85970251/9fa07a00-6d40-4008-8e50-e1bde2824c0d

Additional context Tested with material and material3 themes Tested with ExposedDropdownMenuBox and ModalBottomSheet

luludevmuniz avatar Feb 07 '24 13:02 luludevmuniz

Hi, has this issue been fixed yet? As I just saw https://github.com/JetBrains/compose-multiplatform/issues/4260. But after upgrading to 1.6.0-rc01 it is still crashing when resizing the window after opening a ModalBottomSheet.

LOOHP avatar Feb 14 '24 21:02 LOOHP

Hi, has this issue been fixed yet? As I just saw #4260. But after upgrading to 1.6.0-rc01 it is still crashing when resizing the window after opening a ModalBottomSheet.

The fix didn't get into 1.6.0

eymar avatar Feb 15 '24 06:02 eymar

I have the same error on desktop. Windows 11 Pro 23H2 22631.3155 JDK 17.0.2 compose plugin 1.6.0. Should I open new issue?

vladyslavv-ua avatar Mar 03 '24 15:03 vladyslavv-ua

@vladyslavv-ua This issue is web-specific, it cannot be the same on Desktop. Yes, open a new one please.

MatkovIvan avatar Mar 03 '24 17:03 MatkovIvan

Couldn't reproduce it anymore on 1.6.10-beta01 and afterwards.

luludevmuniz avatar Apr 20 '24 22:04 luludevmuniz

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.

okushnikov avatar Jul 14 '24 15:07 okushnikov