-
Notifications
You must be signed in to change notification settings - Fork 583
Open
Description
Steps to reproduce
- Create a Redux configuration with a repeater field containing switch fields with
required
dependencies - Add the following field structure inside a repeater:
array( 'type' => 'repeater', 'fields' => array( array( 'id' => 'show_link', 'type' => 'switch', 'title' => 'Show Link', 'default' => '0', ), array( 'id' => 'absolute_or_relative_url', 'type' => 'switch', 'title' => 'Absolute URL', 'default' => '0', 'required' => array('show_link', '=', '1'), 'force_output' => true, ), array( 'id' => 'link_to_page', 'type' => 'select', 'data' => 'pages', 'required' => array( array('show_link', '=', '1'), array('absolute_or_relative_url', '=', '1'), ), 'force_output' => true, ), array( 'id' => 'link_to_absolute_url', 'type' => 'text', 'required' => array( array('show_link', '=', '1'), array('absolute_or_relative_url', '=', '0'), ), 'force_output' => true, ), ), )
- Save the Redux configuration and navigate to the admin page
- Enable the first switch (
show_link
) - dependent fields appear correctly - Configure the dependent fields and save
- Refresh the page or navigate away and return
Expected Behavior
- After page refresh, dependent fields should remain visible when their parent conditions are met
- Field visibility should be restored based on saved values
- The same behavior should work consistently both inside and outside repeater fields
Actual Behavior
- Outside repeater: Fields work correctly - dependent fields remain visible after page refresh when conditions are met
- Inside repeater: Dependent fields become hidden after page refresh, even when their parent conditions are satisfied and values are saved correctly
- Field dependencies work on first interaction but fail to restore visibility state after page reload
Any Error Details (PHP/JavaScript)
No PHP errors are generated. JavaScript console shows no errors in dev mode.
Additional Context
Working Configuration (Outside Repeater)
The identical field configuration works perfectly when placed outside of a repeater field. Fields remain visible after page refresh when their conditions are met.
Attempted Solutions
Tried multiple approaches that should work according to Redux documentation:
- Using
force_output => true
on dependent fields - String values (
'1'
,'0'
) instead of integers for comparisons - Nested required arrays:
array(array('field1', '=', '1'), array('field2', '=', '0'))
- Single-level required arrays:
array('field1', '=', '1')
- Various comparison operators (
=
,equals
,!=
)
Environment
- Redux Framework latest
- WordPress latest version
- PHP 8.3+
- Modern browsers (Chrome, Firefox, Safari) - issue occurs in all
Impact
This appears to be a fundamental issue with how Redux handles field dependencies within repeater contexts after page initialization. The field dependency JavaScript logic seems to not properly restore field visibility states for repeater field children when the page loads with existing saved values.
Suggested Investigation Areas
- Redux JavaScript initialization sequence for repeater fields
- Field dependency state restoration logic in repeater contexts
- DOM event binding for dependent fields within dynamically generated repeater items
- Potential timing issues between repeater field rendering and dependency evaluation
This bug significantly impacts the usability of complex repeater configurations that rely on conditional field visibility.
Metadata
Metadata
Assignees
Labels
No labels