One Off the Slack: Dealing with Dialog Damage

Toriq commented on RC01:

Seems also the dialog change to full size was made experimental but as full size by default, breaking previous default value and require optin to experimental to return to normal status :( …it requires to add

properties = DialogProperties(
    usePlatformDefaultWidth = true

The problem is that it’s annotated as ExperimentalAPI so you also need @OptIn(ExperimentalComposeUiApi::class) and the rest of the OptIn standard things to not get warnings / errors on production builds

This affects AlertDialog() as well as other types of dialogs. And, it turns out that this breaking change might itself get broken, based on comments from Google’s Adam Powell:

the edge to edge behavior of AlertDialog in the wake of this seems like we should consider it unintentional

taking a look at a quick fix. Arbitrary dialog content should probably still be able to measure edge to edge since there’s a lot of usages for that sort of thing

Google’s Louis Pullen-Freilich also wrote:

We might need to set a fixed width in AlertDialog, I think there’s a bug for that somewhere - since AlertDialog has a default, but generic dialogs shouldn’t

Adam continued with an explanation of the problem:

compose’s layout system really doesn’t like the remeasuring/TOO_SMALL flag-based handshaking that the ViewRoot path does

and in particular it doesn’t report TOO_SMALL at all, so with the old behavior you wouldn’t get appropriately sized dialogs on large screen devices

(it would never ratchet wider)

Tolriq grumbled:

While previous default way did work mostly ok. I can’t see a nice way to deal with a simple 5 words yes / no dialog and one with a longer text that still should not take the full screen in tablets landscape but still be larger than on phone.

Read the original thread in the kotlinlang Slack workspace. Not a member? Join that Slack workspace here!