Sheet presentationDetents breaks after rapid open/dismiss cycles

Basic Information

Please provide a descriptive title for your feedback:

Sheet presentationDetents breaks after rapid open/dismiss cycles

Which platform is most relevant for your report?

iOS

Description

Steps to Reproduce:

  1. Create a sheet with presentationDetents([.medium])
  2. Rapidly perform these actions multiple times (usually 3-4 times): a. Open the sheet b. Immediately scroll down to dismiss
  3. Open the sheet again
  4. Observe that the sheet now appears at .large size, ignoring the .medium detent

Expected Result: Sheet should consistently maintain .medium size regardless of how quickly it is opened and dismissed.

Actual Result: After rapid open/dismiss cycles, the sheet ignores .medium detent and appears at .large size.

Reproduction Rate:

  • Occurs consistently after 3-4 rapid open/dismiss cycles
  • More likely to occur with faster open/dismiss actions

Configuration:

  • iOS 18
  • Xcode 16.0 (16A242d)
  • SwiftUI
  • Device: iPhone 14

I've filed a Feedback Assistant report for this issue: FB15718814

I experience the same bug. It seems that it was introduced in IOS 18.0 as I couldnt reproduce with IOS 17.5 (and also experienced it with IOS 18.1)

Thanks for filing the bug report, I was able to reproduce the issue and it looks like a bug to me.

Have you tried specifying a custom detent with a height as a way to workaround the issue ?

I'm also seeing this issue on my device:

iOS Version: 18.0.1

Model: iPhone 14 Pro

SwiftUI

XCode 16.1

I'm also seeing this issue on my device:

iOS Version: 18.1.1

Device: iPhone 11

SwiftUI

XCode 16.2

I'm also seeing this issue on my device:

iOS Version: 18.4 Device: iPhone 13 SwiftUI XCode 16.2

And yes, it appears despite specifying a custom detent with a height.

I am seeing this as well in iOS version 18.3.2, iPhone 16 Pro

I'm also seeing this issue on my device:

iOS Version: 18.4 Device: iPhone 16 Pro Max SwiftUI XCode 16.2

And yes, it appears despite specifying a custom detent with a height.

This is still an issue with iOS 18.4.1. It doesn't matter how fast you open the sheets, if you try to present a sheet when another is already opened it will trigger this as well.

Same issues with iOS 18.5

Same here, one way to fix this temporarily is to set detent directly on presentationController within sheet's content

.onAppear {
	guard let windows = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
		return
	}

	if let controller = windows.windows.first?.rootViewController?.presentedViewController,
	   let sheet = controller.presentationController as? UISheetPresentationController {
		sheet.detents = [.medium()]
	}
}
Sheet presentationDetents breaks after rapid open/dismiss cycles
 
 
Q