Skip to content

clearedValue with empty string is equivalent to undefined. #1513

Description

@ssav7912

Scope: Form Renderer/FieldProperties

Description
The default behaviour of a form is to set a value to undefined when the user has cleared it. An API is provided to override this behaviour: https://www.data-driven-forms.org/schema/cleared-value. However, specifying clearedValue = "" is treated the same way as clearedValue = undefined, so that the field property does not appear in getState().values etc.

"" !== undefined, and I think it would be valid behaviour for a cleared text field to actually return an empty string as its value.

Schema

 fields: [
    {
      component: componentTypes.TEXT_FIELD,
      name: "field-with-empty-string-cleared-value",
      label: "Will be set to undefined when field is empty",
      clearedValue: "",
    },
    {
      component: componentTypes.TEXT_FIELD,
      name: "field-without-cleared-value",
      label: "Value will be undefined when field is empty",
    },
    {
      component: componentTypes.TEXT_FIELD,
      name: "field-with-other-cleared-value",
      label: "Value will be null when field is empty",
      clearedValue: null,
    },
  ],

Thanks!

Activity

  1. added
    bugSomething isn't working
    rendererReact form renderer PR
    on Jun 23, 2025
  2. mohith2883 commented on Sep 25, 2025

    @mohith2883

    Can you add hacktoberfest tag
    And assign me

  3. rvsia commented on Sep 25, 2025

    @rvsia
    Contributor

    @mohith2883 Hi,

    hacktoberfest is set as topic for the repository, so it should be included in the program.

  4. mohith2883 commented on Oct 11, 2025

    @mohith2883

    Hey @rvsia , @ssav7912 i have raised a PR can you look into it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrendererReact form renderer PR

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions