Interdependent field conditions not working: "Undefined" value set

Created on 30 January 2025, 30 days ago

Problem/Motivation

After upgrading from 4.0.0-alpha5 to 4.0.0-alpha6 in Drupal 10.3, I experienced some javascript issues.

I added the patch from #3468860 to fix an issue with the visibility conditions, but it wasn't a full fix.

Steps to reproduce

1. Two fields in a field_group: External Data Source Field (using autocomplete style widget) and Entity Reference (using Entity Browser widget).
2. Conditions are set so that at least one of the fields is required and if one has a value, the other is hidden.

When I enter data into the autocomplete field widget, the Entity browser field widget is hidden and gets the value set to "undefined". The same happens if I select an Entity from the Entity browser field widget, the autocomplete is hidden but is set to "undefined".

The hidden field having the value "undefined" triggers form validation errors and causes the Entity browser field widget not to function.

Proposed resolution

Determine why the field values are set to "undefined" when hidden.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Active

Version

4.0

Component

Javascript

Created by

πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @weekbeforenext
  • πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC
  • πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC
  • πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC
  • πŸ‡ΊπŸ‡ΈUnited States weekbeforenext Asheville, NC

    Throwing some breakpoints in the area of conditional_fields.js under the comment "// Override state change handlers for dependents with special effects." and comparing between 4.0.0-alpha5 on Drupal core 10.2.11 and 4.0.0-alpha6 on Drupal core 10.3.10 I see a difference in the handler arguments.

    If I put a breakpoint on `originalHander(e);` this is the comparison:

    4.0.0-alpha5 on Drupal core 10.2.11 (working):

    4.0.0-alpha6 on Drupal core 10.3.10 (not working):

    The Type Error from the screenshot looks something like this:

    TypeError: 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them
        at Function.invokeGetter (<anonymous>:3:28)
        at events.<computed>.handler (https://example.com/modules/contrib/conditional_fields/js/conditional_fields.js?sqx68s:197:13)
        at HTMLDocument.dispatch (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:40035)
        at v.handle (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:38006)
        at Object.trigger (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:70124)
        at HTMLDivElement.<anonymous> (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:70726)
        at Function.each (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:3129)
        at ce.fn.init.each (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:1594)
        at ce.fn.init.trigger (https://example.com/core/assets/vendor/jquery/jquery.min.js?v=3.7.1:2:70701)
        at states.Dependent.reevaluate (https://example.com/core/misc/states.js?v=10.3.10:424:22)
Production build 0.71.5 2024