Is it normal behaviour that when I apply a .toolbar
to a Group
that I see duplicate buttons equal to the number of View
s in the Group
? e.g.
Group {
Text("1")
Text("2")
Text("3")
}
.toolbar {
Button("Hi") {
}
}
Results in 3 toolbar buttons appearing in the UI, like in this screenshot:
If not, then I'll submit feedback about this bug but thought I'd ask first.
Xcode Version 16.0 beta 6 (16A5230g) iPhone 15 Pro Simulator
I think that's expected behaviour. As you've said, it applies the modifier to each item in the Group
.
With .onAppear
it wouldn't make sense to do the same thing three times. All three Text
views appeared, why would you want to call a method three times, or change a variable three times?
For .toolbar
you're adding three Button
s, and I would say that's what you would want to happen, no? Three buttons with the same format, style, etc.