reports icon indicating copy to clipboard operation
reports copied to clipboard

FB13296535: SafeAreaInset layout is wrong while dismissing keyboard with .scrollDismissesKeyboard(.interactively)

Open tngranados opened this issue 1 year ago • 4 comments

  • Date: 2023-10-23
  • Resolution: Open
  • Area: SwiftUI
  • OS: iOS 17.0
  • Type: Incorrect/Unexpected Behavior

Description

When using .safeAreaInset(edge: .bottom) on a ScrollView that also has .scrollDismissesKeyboard(.interactively) set, the view in the safeAreaInset will stay wrongly in the middle of the screen while interactively dismissing the keyboard

To replicate the issue. Create a ScrollView with some elements. Add the .scrollDismissesKeyboard(.interactively) modifier and a view in the bottom with .safeAreaInset(edge: .bottom), a TextField would work best as it would allow you to open the keyboard straight from there. Then, open the keyboard, scroll down to dismiss it.

The expected behaviour would be that the view in the .safeAreaInset(edge: .bottom) would scroll down with the keyboard.

The actual behaviour observed is that .safeAreaInset(edge: .bottom) view would stay in place until the keyboard is fully dismissed, then, quickly move to its correct position.

This is happening with Xcode 15.0 and iOS 17.0 both in the simulator and on device. As far as I can tell, the same happened with iOS 16 and 15.

There is a simple 20 lines of code project attached that replicates the issue. There is also a 6 seconds video that shows the problem.

Files

SafeAreaInsetInteractiveDismissKeyboard.zip

https://github.com/feedback-assistant/reports/assets/593079/f8ff9c91-5f5b-4c34-99ef-163c29784b3b

tngranados avatar Oct 23 '23 09:10 tngranados

This is the SwiftUI Bug. Try my solution: https://github.com/frogcjn/BottomInputBarSwiftUI

frogcjn avatar Jan 10 '24 18:01 frogcjn