-
Notifications
You must be signed in to change notification settings - Fork 58
Closed
Description
Description
When a view that does not return a display list (such as Spacer) is placed in a dynamic container like ForEach, any subsequent views fail to render because their display lists are never combined.
Reproduction
struct ContentView: View {
var body: some View {
VStack {
Color.red
Color.green
ForEach(0 ..< 1) { index in
Spacer()
Color.blue
}
}
}
}In this example, Color.blue fails to render because Spacer before it does not return a display list, causing DynamicPreferenceCombiner to return early.
Root Cause
An item in a dynamic container may be missing a preference if it does not return a display list:
struct MyEmptyView: View, PrimitiveView, UnaryView {
func _makeView(view: _GraphValue<Self>, inputs: _ViewInputs) -> _ViewOutputs {
_ViewOutputs()
}
}Spacer is an example of such a view. When placed in a dynamic list, the preference combining logic returns early, preventing subsequent views from being processed.
Related
- PR Fix DynamicPreferenceCombiner returning early #659 (partial fix that doesn't cover all cases)
Metadata
Metadata
Assignees
Labels
No labels