AlertToast icon indicating copy to clipboard operation
AlertToast copied to clipboard

Popover cuts off `.hud` alert

Open nouun opened this issue 2 years ago • 5 comments

Describe the bug Using .hud in a popover causes the top of it to be cut off.

To Reproduce

struct ContentView: View {
    @State var showPopover = false
    @State var showToast = false
    
    var body: some View {
        Button("Show Popover") {
            self.showPopover.toggle()
        }
        .popover(isPresented: self.$showPopover) {
            List {
                Button("Show Toast") {
                    self.showToast.toggle()
                }
            }
            .toast(isPresenting: self.$showToast) {
                AlertToast(displayMode: .hud, type: .regular, title: "Test")
            }
        }
    }
}

Expected behaviour The toast to be visible.

Screenshots image

nouun avatar Mar 20 '23 13:03 nouun

Same issue when using .hud on MacOS: image

metedata avatar Jun 02 '23 09:06 metedata

This is most likely due to an implementation decision to reference the device's full screen bounds when positioning the toast instead of the presented view's bounds, so it can't take into account anything like sheets or title bars. As far as I know, to fix this you'd need to use an anchor/root view to handle all toast requests, I may work on a PR for this if I get time or fork it off into a separate library.

ImTheSquid avatar Aug 06 '23 16:08 ImTheSquid

Made it.

ImTheSquid avatar Aug 06 '23 18:08 ImTheSquid

may be the same problem? WX20230824-204951@2x toast overlap the navigationTitle

XuWeinan123 avatar Aug 24 '23 12:08 XuWeinan123

This is most likely due to an implementation decision to reference the device's full screen bounds when positioning the toast instead of the presented view's bounds, so it can't take into account anything like sheets or title bars. As far as I know, to fix this you'd need to use an anchor/root view to handle all toast requests, I may work on a PR for this if I get time or fork it off into a separate library.

Hi, I checked out your package to test out if the sheet issue is fixed (AlertToast not completely visible when the view is shown as a sheet) but when I added the .toast modifier on the NavigationStack, it doesn't display it at all. Were you able to fix it? Am I doing something wrong?

kaanselhep avatar Apr 09 '24 20:04 kaanselhep