Skip to content

Commit 9990e83

Browse files
Merge pull request #361 from GetStream/vishal/suggestions-view-fix
Dismiss suggestions view when keyboard is dismissed
2 parents 5c796c4 + f271b13 commit 9990e83

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

src/components/SuggestionsProvider/SuggestionsProvider.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useRef, useState } from 'react';
2-
import { findNodeHandle, View } from 'react-native';
1+
import React, { useEffect, useRef, useState } from 'react';
2+
import { findNodeHandle, Keyboard, View } from 'react-native';
33

44
import SuggestionsList from './SuggestionsList';
55

@@ -22,6 +22,24 @@ const SuggestionsProvider = ({ children }) => {
2222
const messageInputBox = useRef();
2323
const rootView = useRef();
2424

25+
// For the time being, we will just dismiss the suggestions view when keyboard is dismissed.
26+
// TODO: Ideally SuggestionsView should update the position as per keyboard status (open/closed).
27+
// Lets handle it after [email protected] is published
28+
useEffect(() => {
29+
const onKeyboardHidden = () => {
30+
setSuggestionsViewActive(false);
31+
};
32+
33+
const subscription = Keyboard.addListener(
34+
'keyboardDidHide',
35+
onKeyboardHidden,
36+
);
37+
38+
return () => {
39+
subscription.remove();
40+
};
41+
}, []);
42+
2543
const openSuggestions = async (title, component) => {
2644
const [chatBoxPosition, inputBoxPosition] = await Promise.all([
2745
getChatBoxPosition(),

src/components/Thread/__tests__/__snapshots__/Thread.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ exports[`Thread should match thread snapshot 1`] = `
222222
"id": "testID2",
223223
"mutes": Array [],
224224
},
225-
"userAgent": "stream-chat-react-native-ios-1.3.0-kcv.1",
225+
"userAgent": "stream-chat-react-native-ios-1.3.1",
226226
"userID": "testID2",
227227
"userToken": "dummy_token",
228228
"wsBaseURL": "wss://chat-us-east-1.stream-io-api.com",
@@ -880,7 +880,7 @@ exports[`Thread should match thread snapshot 1`] = `
880880
"id": "testID2",
881881
"mutes": Array [],
882882
},
883-
"userAgent": "stream-chat-react-native-ios-1.3.0-kcv.1",
883+
"userAgent": "stream-chat-react-native-ios-1.3.1",
884884
"userID": "testID2",
885885
"userToken": "dummy_token",
886886
"wsBaseURL": "wss://chat-us-east-1.stream-io-api.com",

0 commit comments

Comments
 (0)