Skip to content

TextInput value not trimmed in react-native-country-code-picker #131

@Talha-raj

Description

@Talha-raj

Hi, thanks for the great library!

I'm facing an issue where the TextInput used for searching countries does not automatically trim whitespace from the input. For example, if a user accidentally adds a space before or after a country name (e.g. " Pakistan" or "Pakistan "), the search fails to match the correct result.

Expected Behavior:
The search should ignore leading and trailing whitespace, trimming the TextInput value before processing the search query.

Actual Behavior:
If the user adds spaces at the beginning or end of the input, the search does not return any results.

Steps to Reproduce:

Open the country picker.

Type a country name with leading/trailing spaces (e.g., " Pakistan

Image

").

Observe that no matching results are shown.

Suggested Fix:
Apply .trim() to the search value before filtering the list of countries.

Let me know if you'd like me to submit a PR for this.

Thanks again!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions