Skip to content

Commit 0fdff4f

Browse files
Dismiss suggestions view when keyboard is dismissed
1 parent 5c796c4 commit 0fdff4f

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
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(),

0 commit comments

Comments
 (0)