PageSheet icon indicating copy to clipboard operation
PageSheet copied to clipboard

[Bug] Sheet detent is not maintained after back to foreground

Open chienpm304 opened this issue 7 months ago • 3 comments

Describe the bug Sheet detent is not maintained after back to foreground, e.g when we set detent to medium and present it, it work for just normal until we home app to background and reenter app, when app is back to foreground the sheet detents seems to be reset to large.

To Reproduce Steps to reproduce the behavior (Example app): 0. Set the sheet detent to [.medium]

  1. Open app
  2. Click on Open sheet
  3. Home app
  4. Reopen app

Expected behavior After reopen app the sheet detent should maintains as before medium.

Screenshots https://github.com/user-attachments/assets/26ae9515-0314-497a-805c-fbfbb15fce89

Smartphone (please complete the following information):

  • Device: iPhone 14 Plus
  • OS: iOS 16.1
  • Browser [e.g. stock browser, safari]
  • Version: 1.2.5

chienpm304 avatar May 12 '25 08:05 chienpm304

Feel free to give a shot fixing it. That said -- this whole API is part of SwiftUI now (and better in some ways), so I would consider this "unmaintained".

ericlewis avatar May 13 '25 06:05 ericlewis

Thank you for prompt reply, I came up with a workaround by listening the UIApplication.willEnterForegroundNotification event to reset the configuration the inside HostingController's lifecycle, this should work.

chienpm304 avatar May 13 '25 07:05 chienpm304

if you have a well tested PR feel free to put it up

ericlewis avatar May 13 '25 08:05 ericlewis