Is it documented anywhere that #SwiftUI's background(_:in:) API implicitly calls containerShape, even prior to 26?

This still seems totally unexpected to me

https://developer.apple.com/documentation/swiftui/view/background(_:in:fillstyle:)

I was only able to "confirm" the implicit containerShape call by explicitly setting a containerShape before calling background(_:in:)

Everything I've searched (and Claude) tells me this shouldn't be happening and it should require explicit containerShape or ConcentricRectangle/ContainerRelativeShape

#SwiftUI

background(_:ignoresSafeAreaEdges:) | Apple Developer Documentation

Sets the view’s background to a style.

Apple Developer Documentation
@shnhrrsn guess Claude didn’t read the docs ¯\_(ツ)_/¯

@dlx Not sure if I'm still missing it, but it's not clear to me from that page either that if I do `.background(.red, in: shape)` it will implicitly call `containerShape(shape)`

The way I'm reading it, it's saying that if I already have a containerShape set, then calling background will inherit that shape

@shnhrrsn oh sorry, you meant .containerShape(_:), I misunderstood – yeah, that doesn’t seem be documented, in fact, this is evidently wrong https://developer.apple.com/documentation/swiftui/view/background(_:in:fillstyle:)#:~:text=This%20modifier%20is%20a%20convenience%20method%20for%20placing%20a%20single%20shape%20behind%20a%20view.

I assume if go through the non-insettable code path things work as expected?

background(_:in:fillStyle:) | Apple Developer Documentation

Sets the view’s background to an insettable shape filled with a style.

Apple Developer Documentation

@dlx Yep, non-insettable is fine.

Had claude code dig into SwiftUICore and it was able to confirm what I was seeing at runtime:

https://gist.github.com/shnhrrsn/6fe5155a4d8de648079d494c76783c11

This really should be documented…

"So: whenever you use the InsettableShape overload of .background(_:in:fillStyle:), SwiftUI's graph setup for that modifier calls _ViewInputs.setContainerShape with your shape — which is the internal plumbing behind .containerShape(...). The non-insettable background(_:in:) with Shape does not do this[...]"

background-shape.sh

GitHub Gist: instantly share code, notes, and snippets.

Gist