Skip to content

fix(react-components/text-field): undefined value should not be displayed #497

Closed
@malikarami

Description

@malikarami

Describe the bug
The textfield is rendering undefined as a value.

To Reproduce

import { TextField } from '@tapsioss/react-components/TextField';

const Test = () => {

  // the initial value of the state is undefined
  const [phoneNumber, setPhoneNumber] = useState<string>();
  
  return (
    <div>
      <TextField
                placeholder="شماره همراه"
                type="tel"
                maxLength={11}
                value={phoneNumber}
                onChange={(e) => setPhoneNumber((e.target as HTMLInputElement).value)}
       />
    </div>
  )
}

Expected behavior
undefined should be treated as empty string and the placeholder should be rendered instead of the "undefined" string.

Screenshots

Image

Desktop (please complete the following information):

  • OS: [e.g. iOS]: MacOS 14
  • Browser [e.g. chrome, safari]: Chrome
  • Version [e.g. 22]: ^0.17.1

Additional context Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions