stream-chat-react-native icon indicating copy to clipboard operation
stream-chat-react-native copied to clipboard

KeyboardCompatibleView.removeListeners crash even when disabled

Open DobritoiuBogdan747 opened this issue 6 years ago • 2 comments

Describe the bug KeyboardCompatibleView returns an error when I take app into background or close the the screen.

Error: 'TypeError cannot read property 'remove' of undefined' KeyboardCompatibleView.removeListeners

I've tried to add disableKeyboardCompatibleView prop as well as creating a component like the cookbook says:

const MyKeyboardCompatibleView = ({ children, ...props }) => {
    return (
        <ErrorBoundary>
            <KeyboardCompatibleView enabled={false}>
                <KeyboardAvoidingView
                    behavior={"padding"}
                    keyboardVerticalOffset={isIphoneX ? 56 : 20}
                    contentContainerStyle={{ flexGrow: 1, height: '100%' }}>
                    {children}
                </KeyboardAvoidingView>
            </KeyboardCompatibleView>
        </ErrorBoundary>
    )
}

I've also tried without the KeyboardAvoidingView just in case it interfered but it still crashes. I've added the ErrorBoundary to stop it from crashing when closing modal but it will still crash when taking app into 'background/inactive' state.

Working case but not fully If I return children instead of what I returned at the top, for KeyboardCompatibleView prop then the error does not appear but I am not able to trigger the attach button. It needs a KeyboardCompatibleView to be able to open the transparent overlayed file/image selector.

Dev environment info:

  • stream-chat-react-native 0.11.0
  • react-native 0.61.5
  • iOS device/emulator

Steps to reproduce Case 1

  1. disableKeyboardCompatibleView on Channel prop as true
  2. take app into background/inactive or close modal and it will show error with KeyboardCompatibleView.removeListener and crashing the app

Case 2

  1. return children for prop MyKeyboardCompatibleView
  2. try to press attach button it won't do anything

Expected Behaviour If I add enabled={false} on KeyboardCompatibleView or add disableKeyboardCompatibleView then it should let the attach button be triggered. Or if I have it on enabled={false} don't add listeners? or don't remove listeners if it is disabled?

Screenshots Screenshot 2020-06-16 at 10 16 10

DobritoiuBogdan747 avatar Jun 16 '20 07:06 DobritoiuBogdan747

Hey @DobritoiuBogdan747 can you please upgrade to 0.12.0 and check. I have fixed issues regarding disableKeyboardCompatibleView prop on Channel component.

vishalnarkhede avatar Jun 16 '20 08:06 vishalnarkhede

Working properly. Thanks!

DobritoiuBogdan747 avatar Jun 16 '20 17:06 DobritoiuBogdan747