Skip to content

Input type 'email' as controlled component does not control white spaces #6368

Closed
@marcolanaro

Description

@marcolanaro

A controlled input filed of type email behave differently from a controlled field of type text.
If you manage a controlled input field of type email, the actual state and the rendered DOM are different if the user digit spaces, e.g. ' '.

With an input element like this:
<input type="text" value={'stringFromTheState'} />
if you try to digit letters or spaces, you will always get rendered the string 'stringFromTheState'.

With an input element like this:
<input type="email" value={'stringFromTheState'} />
if you try to digit letters you will always get rendered the string 'stringFromTheState'.
if you try to digit spaces you will get a new rendered string that compose the state with the spaces.

This is problematic is before saving the state you need to validate the field and force it to do something smart like strip the white spaces.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions