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

AlertDialog is too narrow by default #2836

Closed
m-sasha opened this issue Mar 7, 2023 · 1 comment · Fixed by JetBrains/compose-multiplatform-core#433
Closed

AlertDialog is too narrow by default #2836

m-sasha opened this issue Mar 7, 2023 · 1 comment · Fixed by JetBrains/compose-multiplatform-core#433
Assignees
Labels
bug Something isn't working

Comments

@m-sasha
Copy link
Contributor

m-sasha commented Mar 7, 2023

Describe the bug
If you don't specify a concrete width for an AlertDialog, it attempts to display it as narrowly as possible, which often leaves a lot of unused horizontal space that could be used for a better result.

Reproducer:

@OptIn(ExperimentalMaterialApi::class)
fun main() = singleWindowApplication(
    state = WindowState(width = 400.dp, height = 300.dp),
) {
    MaterialTheme{
        AlertDialog(
            onDismissRequest = {},
            title = { Text("This is the title") },
            text = { Text("This is the text") },
            confirmButton = { }
        )
    }
}

Affected platforms
Select one of the platforms below:

  • All

Versions

  • Compose Multiplatform version: 1.3.0

Expected behavior
The alert dialog should be wider, not breaking lines as long as there is more horizontal room.

Screenshots
image

@m-sasha m-sasha added the bug Something isn't working label Mar 7, 2023
@m-sasha m-sasha self-assigned this Mar 7, 2023
@m-sasha
Copy link
Contributor Author

m-sasha commented Mar 11, 2023

Another important issue caused by the same problem is that widthIn is ignored:

@OptIn(ExperimentalMaterialApi::class)
fun main() = singleWindowApplication(
    state = WindowState(width = 500.dp, height = 400.dp),
) {
    MaterialTheme{
        AlertDialog(
            modifier = Modifier.widthIn(max = 400.dp).padding(horizontal = 30.dp),
            onDismissRequest = { },
            title = { Text("This is the title") },
            text = { Text("This is the text This is the text This is the text This is the text This is the text This is the text This is the text") },
            confirmButton = {}
        )
    }
}

image

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

Successfully merging a pull request may close this issue.

1 participant