How to force multiline in ConfirmationDialog item in SwiftUI

105 views Asked by At

I have a confirmation dialog with one entry being a bit too long to be display in a single line, so it gets cut in the middle:

Screenshot of confirmation dialog with text too long for one line

Nothing that I've tried has worked, I'm a bit out of ideas here.

Though there is one notable thing being that it is possible somehow: if I show the dialog, then increase the text size (from accessibility options) then at some point it will wrap around on multiple lines! And at this point if I keep the dialog open and I go back to a smaller text size, it will even stay on multiple lines, this being the result I would like initially. And of course if I close and reopen the dialog, it goes back to being single line and cut to fit

Screenshot of confirmation dialog with large text from accessibility options, wrapping on multiple lines

Tried setting height with .frame(height:, also using .fixedSize(, but didn't work

Here is a small snippet to reproduce

import SwiftUI

struct ConfirmationDialogTest: View {
    @State private var showDialog = false
    
    var body: some View {
        VStack {
            Button("Show dialog") {
                showDialog = true
            }
        }
        .confirmationDialog("Confirmation", isPresented: $showDialog) {
            Button("OK") {}
            Button("Very long text that will eventually be too long to be displayed on only one single line") {}
            Button("Delete", role: .destructive) {}
        }
    }
}
0

There are 0 answers