stream-chat-swiftui icon indicating copy to clipboard operation
stream-chat-swiftui copied to clipboard

Not possible to dismiss keyboard when coming from empty state

Open fceldeiro opened this issue 1 year ago • 2 comments

What did you do?

  • Present a ChatChannelView of a channel without any messages and a custom empty view with the keyboard up.
  • Send a message
  • Trying to dismiss the keyboard swiping down or tapping on the background doesn't work forcing to dismiss and open the chat again for it to work

What did you expect to happen?

  • Dismissal behavior should work regardless if it's coming from an empty state or not.

What happened instead?

It seems that the flag @State private var keyboardShown = false in MessageListView when switching from empty to having messages it remains in false since there is no keyboard trigger.

So the logic in line 239 of MessageListView doesn't trigger in this scenario. if keyboardShown && diff < -20 { keyboardShown = false resignFirstResponder() } if offsetValue > 5 { onMessageAppear(0, .down) }

GetStream Environment

GetStream Chat version: 4.54.0 GetStream Chat frameworks: StreamChat, StreamChatSwiftUI iOS version: 17.4 Swift version: >5 Xcode version: 15.3 Device: iphone 15

fceldeiro avatar May 13 '24 16:05 fceldeiro

Hi @fceldeiro,

What does the empty view contain? A screenshot would help as well, not sure I fully understand the issue.

Thanks, Martin

martinmitrevski avatar May 14 '24 09:05 martinmitrevski

Hello @martinmitrevski I made a video, maybe it helps to understand.

https://github.com/GetStream/stream-chat-swiftui/assets/1914557/c6524531-b2af-4d4f-b39c-e2be66cfc5a3

I don't think the problem itself it's on the empty (in the video is just a view with a dynamic hstack but it's empty there) but rather on when transitioning from empty to the actual message list. If i close this chat and open it again i can dismiss the keyboard by either tapping on the back or scrolling down hard but this same behavior does not work from in the scenario i mention.

From MessageListView this doesn't trigger in this scenario, since the keyboard is already presented so the snippet i pasted before never pass the check since keyboardShown remains in false .onReceive(keyboardDidChangePublisher) { visible in if currentDateString != nil { pendingKeyboardUpdate = visible } else { DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) { keyboardShown = visible } } }

fceldeiro avatar May 14 '24 12:05 fceldeiro

Hi @fceldeiro This issue is fixed in 4.58.0 Thank you for reporting!

laevandus avatar Jun 27 '24 14:06 laevandus

Hello @laevandus , i've just tried 4.58.0 and the issue remains. If the keyboard is up when sending a message in a chat without messages i cannot dismiss the keyboard while swiping after.

fceldeiro avatar Jun 28 '24 15:06 fceldeiro