MenuBarExtra with .window style has layout issue with ScrollView

I tried to create an menubar application but since it contains multiple View in a Scroll, as you may imagine, i had to use .menuBarExtraStyle(.window). The point is: the first time I open the menu the height seems to layout properly, but from the second time on, the view resizes to a certain smaller height amount. You may try with this simple snippet:

        MenuBarExtra("", systemImage: "info") {
            ScrollView {
                VStack(alignment: .leading) {
                    ForEach(0..<100) {
                        Text("Row \($0)")
                    }
                }
            }
        }
        .menuBarExtraStyle(.window)

Changing .menuBarExtraStyle(.window) to .menuBarExtraStyle(.menu) fixes the problem but of course you can't build your own layout, functionalities, etc... just display.

Even setting a maximum height - .frame(maxHeight: maxHeight) - for the ScrollView, doesn't seem to affect this behavior.

Did anyone faced this issue? Maybe there's a proper way to proceed and build this kind of layout?

Post not yet marked as solved Up vote post of matryx87 Down vote post of matryx87
307 views

Replies

Ever find a solution to this? I'm seeing the same issue. Adding .frame(maxHeight: maxHeight) does seem to work for me though. However, this does not solve my issue as the window renders too large on subsequent openings.

Hey I think i figured it out.

Try using .fixedSize() on the scrollview. In my case I had to use .fixedSize(horizontal: false, vertical: true)