solved keyboard not opening bug and removed unused code

This commit is contained in:
Sadaqat Ali 2022-04-16 13:24:52 +05:00
parent b43e256a83
commit a1deef1913
2 changed files with 4 additions and 18 deletions

View File

@ -178,7 +178,10 @@ const MarkdownEditorView = ({
useEffect(() => {
if (autoFocusText && inputRef && inputRef.current && draftBtnTooltipRegistered) {
// added delay to open keyboard, solves the issue of keyboard not opening
setTimeout(() => {
inputRef.current.focus();
}, 1000);
}
}, [autoFocusText]);

View File

@ -28,25 +28,9 @@ const QuickReplyModal = ({}: QuickReplyModalProps, ref) => {
const [selectedPost, setSelectedPost] = useState(null);
const [commentValue, setCommentValue] = useState('');
const [isSending, setIsSending] = useState(false);
const [isKeyboardVisible, setKeyboardVisible] = useState(false);
const sheetModalRef = useRef<ActionSheet>();
const inputRef = useRef<TextInput>(null);
// keyboard listener hook for checking if keyboard is active/inactove
useEffect(() => {
const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => {
setKeyboardVisible(true); // or some other action
});
const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => {
setKeyboardVisible(false); // or some other action
});
return () => {
keyboardDidHideListener.remove();
keyboardDidShowListener.remove();
};
}, []);
// reset the state when post changes
useEffect(() => {
setCommentValue('');
@ -69,7 +53,6 @@ const QuickReplyModal = ({}: QuickReplyModalProps, ref) => {
// handle close press
const _handleClosePress = () => {
sheetModalRef.current?.setModalVisible(false);
setKeyboardVisible(false);
};
// navigate to post on summary press
const _handleOnSummaryPress = () => {