SwiftUI "listRowBackground" incorrectly changes row height in macOS

Originator:mkflint
Number:rdar://FB7651473 Date Originated:4 April 2020
Status:Open Resolved:
Product:SwiftUI Product Version:
Classification:Bug Reproducible:Yes
 
SwiftUI’s “listRowBackground” function influences the row height when running in macOS, but does not for iOS.

1. Make a SwiftUI app containing a List object
2. Add a tall row to the List, using multiple Text objects in a VStack
3. Observe that the row height is calculated correctly
4. Add “listRowBackground(Color.yellow)” to the row
5. Observe that the row height is correct for iOS, but incorrect for macOS

struct ContentView: View {
	var body: some View {
		List {
			VStack(alignment: .leading) {
				Text("Here's to the crazy ones.")
				Text("The rebels.")
				Text("The troublemakers.")
				Text("The round pegs in the square holes.")
			}
			.listRowBackground(Color.yellow) // comment out to get the correct row height
		}
	}
}

struct ContentView_Previews: PreviewProvider {
	static var previews: some View {
		ContentView()
			.previewLayout(.fixed(width: 400, height: 400))
	}
}

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!