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

iOS. AlertDialog has a wrong layout if it is shown at the app startup #3540

Closed
igordmn opened this issue Aug 21, 2023 · 3 comments
Closed

iOS. AlertDialog has a wrong layout if it is shown at the app startup #3540

igordmn opened this issue Aug 21, 2023 · 3 comments
Assignees
Labels
bug Something isn't working ios p:high High priority

Comments

@igordmn
Copy link
Collaborator

igordmn commented Aug 21, 2023

Compose 1.5.0-rc01, iOS

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material.Button
import androidx.compose.material.MaterialTheme
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
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.graphics.Color

@Composable
fun App() {
    MaterialTheme {
        Box(Modifier.fillMaxSize().background(Color.White)) {
            var isDialogOpen by remember { mutableStateOf(true) }  // set to false to see how dialog should look
            Button(onClick = { isDialogOpen = true }) {
                Text("Open")
            }
            if (isDialogOpen) {
                androidx.compose.material3.AlertDialog(
                    onDismissRequest = { },
                    confirmButton = {
                        Button(onClick = { isDialogOpen = false }) {
                            Text("OK")
                        }
                    },
                    title = { Text("Alert Dialog") },
                    text = { Text("Lore ipsum") },
                )
            }
        }
    }
}

Showing at startup:

Assumptions:

  1. the initial contaizer size is zero, the initial density is 1f
  2. the content doesn't react on the container size and density changes.

Showing at the button press (expected):

Priority high, because we can have hidden races, and there can be some use cases (restoring state at the app startup)

@igordmn igordmn added bug Something isn't working p:high High priority ios labels Aug 21, 2023
@igordmn igordmn changed the title iOS. AlertDialog has a wrong layout if it is shown initially iOS. AlertDialog has a wrong layout if it is shown at the app startup Aug 21, 2023
@gastsail
Copy link

gastsail commented Aug 22, 2023

Is this the same if we add modifier = Modifier.fillMaxWidth() to the Texts inside the AlertDialog ?

@MatkovIvan
Copy link
Member

It was fixed in 1.5.0-rc04

@MatkovIvan
Copy link
Member

It was combination of #3434 and #3778

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ios p:high High priority
Projects
None yet
Development

No branches or pull requests

3 participants