Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to dismiss keyboard when coming from empty state #481

Open
fceldeiro opened this issue May 13, 2024 · 2 comments
Open

Not possible to dismiss keyboard when coming from empty state #481

fceldeiro opened this issue May 13, 2024 · 2 comments

Comments

@fceldeiro
Copy link

fceldeiro commented May 13, 2024

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

@martinmitrevski
Copy link
Contributor

Hi @fceldeiro,

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

Thanks, Martin

@fceldeiro
Copy link
Author

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

RPReplay_Final1715688549.MP4

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 } } }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants