Home Forums Bug Reports User settings for collapsed, nested flexible content fields not saved


User settings for collapsed, nested flexible content fields not saved

  • When using a flexible content field inside another flexible content field, if a user collapses the parent layout, this settings gets saved. If a user then uncollapses this same parent layout, it does not get saved in acf_user_settings (resulting in a user having to expand it every time unless the user’s acf_user_settings value is cleared.

    ACF PRO: 5.4.8
    Wordpress 4.6.1

    I’ve verified this on a clean WordPress install with no plugins except ACF Pro activated.

    Upon inspection, the issue appears to happen at line 1160 in acf-pro-input.js. When acf.do_action(‘show’, $layout, ‘collapse’) is called, the value of this.$field and this.$values changes to the inner, nested flexible content field. As such, when this.sync() is called on line 1173, it does not properly update acf_user_settings.

    I’ve had a hard time understanding why those values change when acf.do_action(‘show’) is called. But the following patch, which stores the values before do_action and resets them afterwards, does resolve the issue if it’s helpful.

    --- /advanced-custom-fields-pro/pro/assets/js/acf-pro-input.js 
    +++ /advanced-custom-fields-pro/pro/assets/js/acf-pro-input.js 
    @@ -1147,6 +1147,14 @@
          var $layout = e.$el.closest('.layout');
    +     // store for resetting before sync()
    +     // - these values otherwise change when collapsing a flexible 
    +     // field that includes a flexible field, when acf.do_action('show')
    +     // is called
    +     var _field = this.$field,
    +         _values = this.$values;
          // render
          // - do this before calling actions to avoif focusing on the wrong field
          this.render_layout_title( $layout );
    @@ -1169,6 +1177,11 @@
    +     // reset to original field and values
    +     this.$field = _field;
    +     this.$values = _values;
          // sync collapsed order
  • Please submit this to support by opening an new support ticket This is the fasted way to report a bug to the developer.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.