forms that intentionally reuse a key with mutually exclusive conditionals

Offen
#651 3 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
64/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
react, typescript
Bereich
frontend

Rechercherichtung

Reproduce the issue with the two mutually exclusive name fields in the report, using a blank submission. Start by tracing the visibility check and clearComponentOnHide() behavior described in the issue, then follow how deleteValue() affects the shared key. Done means entering a valid name no longer clears the shared value or triggers the required-field validation message.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug
I was using Formio/React 5.3.0 but when I upgraded to 6.2.1 I found that duplicate key reuse for mutually exclusive conditions always throws validation error.

In @formio/react 5.3.0 (formiojs 4), clearOnHide only runs when visibility changes:

if (this.visible !== visible) {
  this.visible = visible; // setter may clear
}

Once the edit field is already hidden, later condition checks leave data.name alone, so the create field keeps working.

In @formio/react 6.2.1 (@formio/js 5), every condition check clears a hidden field:

if (this.visible !== visible) {
  this.visible = visible;
}
this.clearComponentOnHide(); // always, while hidden

So on create, the hidden edit name repeatedly does deleteValue() on the shared data.name. The create field then fails required, and customMessage makes it look like the pattern error.

below is my two components with the same name but conditional:

{
    "key": "name",
    "type": "textfield",
    "input": true,
    "label": "Name",
    "disabled": true,
    "validate": {
        "pattern": "^[a-zA-Z0-9\\s]*$",
        "required": true,
        "maxLength": 80,
        "customMessage": "Invalid name; must contain only letters, numbers or spaces "
    },
    "autofocus": true,
    "tableView": true,
    "spellcheck": false,
    "showCharCount": true,
    "customConditional": "show = data.submissionUuid.length > 0",
    "hideOnChildrenHidden": false
},
{
    "key": "name",
    "type": "textfield",
    "input": true,
    "label": "Name",
    "validate": {
        "pattern": "^[a-zA-Z0-9\\s]*$",
        "required": true,
        "maxLength": 80,
        "customMessage": "Invalid name; must contain only letters, numbers or spaces "
    },
    "autofocus": true,
    "tableView": true,
    "spellcheck": false,
    "showCharCount": true,
    "customConditional": "show = data.submissionUuid.length === 0",
    "hideOnChildrenHidden": false
}

To Reproduce
Steps to reproduce the behavior:

  1. create a form with customConditionals has shown above
  2. use that form with a Form component with no submission data or a blank object.
  3. on entry of the name you will always get the customMessage.

Expected behavior
I would expect it not to deleteValue() on the shared data.name so we will not get a custom validation message if the text entered is valid.

Screenshots
here is a screen shot of what i with mutually exclusive conditionals

Image
Vorherrschende Sprache
TypeScript
Sterne
371
Forks
309
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus formio/react

Alle Issues in formio/react

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.