Skip to content

Searchbar - Hiding the keyboard should not automatically trigger cancel() #3221

@ankitmaloo

Description

@ankitmaloo

Explain what you did (Required)

I am building a search bar for my app. On ios, hiding the keyboard works as expected, but on android hiding the keyboard hides the search results.

Expected behavior (Required)
I should be able to dismiss keyboard on android without also triggering the cancel function.

Describe the bug (Required)
On android, this is the function: (SearchBar-android.tsx 102-108)

 Keyboard.addListener('keyboardDidHide', this._keyboardDidHide);
  }

  _keyboardDidHide = () => {
    this.cancel();
  };

  componentWillUnmount() {
    Keyboard.removeListener('keyboardDidHide', this._keyboardDidHide);
  }

You see, as soon as I hide the keyboard, the cancel function is executed. The same function is also executed on Canceling the search via the back button on android. This is breaking a lot of things for me, when I want users to see the search results by dismissing the keyboard.

To Reproduce (Required)

  1. Display a search bar.
  2. Write an onCancel function. iN the function, write this: "console.log("in cancel function")
  3. test on your android phone. Type something, and then press enter/ok etc on your keyboard to dismiss the keyboard.
  4. See if the cancel function is executed.
  5. Do the same on iOS. See if the cancel function is executed.

Screenshots (Required)

Not applicable.

Your Environment (Required):

software version
react-native-elements 3.4.2
react-native 0.63.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions