Skip to content

[1.6.7] Side-effect in Firefox / Form.validateField method #372

@CugeDe

Description

@CugeDe

Testing environment

  • OS: Archlinux 5.0.0 x86_64 | Archlinux 5.0.1 x86_64
  • NPM: v6.4.1 | v6.7.0 | v6.9.0
  • node: v10.15.3 | v11.11.0
  • react-advanced-form: v1.5.* | v1.6.7
  • Browser: Google Chrome (working but not always) | Firefox (not working at all)

What

Current Behaviour

  • Provide a Form component with a Select field component (created with createField) and using React-Select component. This select field is multiple.
  • Select one of the available values
  • The field is updated and renders the selected value
  • Select additional values
  • The field is not updated and ignores the selected values

Expected Behaviour

  • The field should not ignore additional values

Investigation result

  • When an additional value is selected Form.validateField is called (line 488).
    See here

Here, forceProps is always false.

On Chrome:

const fields = explicitFields || this.state.fields
let fieldProps = forceProps
      ? explicitFieldProps
      : R.path(explicitFieldProps.fieldPath, fields)

// This branch is always taken in my case
if (fieldProps) {
    console.log(fieldProps.value)
    // -> Array of two values (IMO, this means that the field values were
    // updated BEFORE the validation...)
}

fieldProps = fieldProps || explicitFieldProps

On Firefox:

const fields = explicitFields || this.state.fields
let fieldProps = forceProps
      ? explicitFieldProps
      : R.path(explicitFieldProps.fieldPath, fields)

// This branch is always taken in my case
if (fieldProps) {
    console.log(fieldProps.value)
    // -> One value (IMO, this means that the field values were not
    // updated, kinda logical because validation should allows it or not)
}


fieldProps = fieldProps || explicitFieldProps

More

I was not able to reproduce the problem on Debian unstable (my only other testing environment).

Here's a code sandbox (See here) showing the bug I have on Archlinux with Firefox.

On the sandbox, I can't even select a single value and the bug also happens when the isMulti = false.

Resolution

I don't really understand why you are using R.path(explicitFieldProps.fieldPath, fields).
I tried removing the line and it works (same as setting forceProps to true).

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