Problem

Field Group Complete can leave a field group tab marked incomplete when a conditional gate changes after validation errors have already been shown.

This can happen when a boolean single-checkbox field controls whether other fields inside the same field group are shown, hidden, required, or required-on-publish.

screenshot showing an gate making a field not required and field group is still marked incomplete.

Steps to reproduce

  1. Create a field group tab.
  2. Add a boolean field using the single-checkbox widget.
  3. Add another field inside the same field group.
  4. Configure the second field so that its visibility required state depends on the boolean checkbox.
  5. Submit the form in a state that causes the dependent field to show a validation error.
  6. Tick the checkbox so that the dependent field is hidden or no longer required.

Expected behavior

The field group completeness badge should update when the checkbox changes.

If the dependent field is hidden or no longer required, it should not continue to keep the field group marked incomplete or errored.

Actual behavior

The field group tab remains incomplete, even after the checkbox changes the state of the dependent field.

Notes

This appears to be related to stale validation state after a conditional field changes. The current field-specific update behavior is not sufficient when the change that affects completeness comes from a another field rather than from the errored field itself.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jcandan created an issue. See original summary.

jcandan’s picture

I think there are two related but separable concerns here.

First, Field Group Complete (FGC) needs to recompute when a gate field changes, not only when the currently errored field itself changes (or blurs). In this case, the boolean checkbox is what changes whether the dependent field should count toward completeness, so field-specific handling on the errored dependent field is not enough.

Second, I do not think FGC necessarily needs to fully interpret the Form States API #states expression in order to decide completeness. It may be reasonable to inspect data-drupal-states to discover that one field depends on another and therefore know when to trigger a recompute. But the actual completeness calculation may need to stay generic: look at the current rendered state of the form and decide whether the relevant required, required-on-publish, or errored controls are currently visible/applicable inside the field group.

That avoids making FGC responsible for reimplementing all of Drupal states logic or custom states semantics. For example, require_on_publish is not a core state with a universal meaning; it is meaningful because another module adds behavior around it. Similarly, Conditional Fields may use states-style expressions, but the important result for FGC is whether the field is currently visible/applicable and should count.

So my current leaning is:

  • Maybe use state/dependency information if helpful to know when a gate change should trigger a recompute.
  • Use the actual DOM/form state to decide whether a field counts toward completeness.

That seems like a reasonable middle ground: FGC can react to conditional dependencies without becoming a second implementation of Drupal states or of module-specific states such as required-on-publish.

jcandan’s picture

Assigned: jcandan » Unassigned
Status: Active » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • jcandan committed 1afb9bf6 on 1.x
    fix: #3590213 Completeness badge does not update when a conditional gate...