Skip to content

Paste handling only trims whitespace at start/end, not inside the pasted code #417

@ranielison

Description

@ranielison

When pasting a code into PinCodeTextField, the package already applies a normalization step to remove unwanted spaces from the pasted value. However, this normalization only trims whitespace at the beginning and end of the string.

In some real-world scenarios (e.g. copying codes from SMS, email clients, or messaging apps), the pasted code may contain spaces in the middle, such as:

"12 34 56"

Currently, this results in the internal spaces being preserved, which breaks the expected behavior for PIN / OTP inputs that require a continuous numeric string.

After checking the source code, I found that the current implementation only uses a trim()-like approach, which does not handle inner whitespace.

Expected behavior

All whitespace characters should be removed from the pasted value, including those inside the string, so that:

"12 34 56"

becomes:

"123456"

Additional context

This behavior is especially important for OTP / verification code flows, where users often paste codes from external apps that may introduce spaces automatically.

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