Yoast / yoast-acf-analysis

WordPress plugin that adds the content of all ACF fields to the Yoast SEO score analysis.
https://wordpress.org/plugins/acf-content-analysis-for-yoast-seo/
GNU General Public License v3.0
61 stars 20 forks source link

Nested Repeater JS Errors when trying to delete repeater row #147

Open precisenm opened 6 years ago

precisenm commented 6 years ago

Please give us a description of what happened.

I have some nested repeaters, I've included the json backup below. The repeater fields in question are those under 'exp_by_client'. Basically you can add everything in the backend perfectly and display on the front end just fine. But if you try to delete any of the main row's or nested row's it throws up a JS error, doesn't delete and makes the entire repeater section unusable until you refresh the page.

The JS error is below:

select2.full.min.js:1 The select2('data') method was called on an element that is not using Select2. (anonymous) @ select2.full.min.js:1 select2.full.min.js:1 Uncaught TypeError: Cannot read property 'data' of undefined at HTMLSelectElement. (select2.full.min.js:1) at Function.each (load-scripts.php:2) at a.fn.init.each (load-scripts.php:2) at a.fn.init.a.fn.select2 (select2.full.min.js:1) at yoast-acf-analysis.js:695 at Function.m.map.m.collect (load-scripts.php:411) at Scraper.scrape (yoast-acf-analysis.js:681) at yoast-acf-analysis.js:314 at Function.m.each.m.forEach (load-scripts.php:411) at Collect.getFieldData (yoast-acf-analysis.js:313) select2.full.min.js:1 The select2('data') method was called on an element that is not using Select2. (anonymous) @ select2.full.min.js:1 select2.full.min.js:1 Uncaught TypeError: Cannot read property 'data' of undefined at HTMLSelectElement. (select2.full.min.js:1) at Function.each (load-scripts.php:2) at a.fn.init.each (load-scripts.php:2) at a.fn.init.a.fn.select2 (select2.full.min.js:1) at yoast-acf-analysis.js:695 at Function.m.map.m.collect (load-scripts.php:411) at Scraper.scrape (yoast-acf-analysis.js:681) at yoast-acf-analysis.js:314 at Function.m.each.m.forEach (load-scripts.php:411) at Collect.getFieldData (yoast-acf-analysis.js:313)

Please describe what you expected to happen and why.

I expected the containing row or nested row to be deleted, instead a JS error is thrown and disabled all ACF functionality on the page.

How can we reproduce this behavior?

//////////////////// EXPORTED FIELD \\\\\\\\\\ [ { "key": "group_5a6351ee273d0", "title": "Industries", "fields": [ { "key": "field_5afbfd678cc7f", "label": "Select Industry Taxonomy", "name": "select_industry_taxonomy", "type": "taxonomy", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "taxonomy": "market", "field_type": "select", "allow_null": 0, "add_term": 1, "save_terms": 1, "load_terms": 1, "return_format": "object", "multiple": 0 }, { "key": "field_5aafebb51b67a", "label": "Main Intro", "name": "", "type": "tab", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "placement": "top", "endpoint": 0 }, { "key": "field_5a635304aab05", "label": "Industries Main Title", "name": "industries_main_title", "type": "text", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5aafebde1b67b", "label": "Industries Image Gallery", "name": "industries_main_image", "type": "gallery", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "min": 1, "max": 8, "insert": "append", "library": "all", "min_width": "", "min_height": "", "min_size": "", "max_width": "", "max_height": "", "max_size": "", "mime_types": "" }, { "key": "field_5a6351fcaab02", "label": "Industries Intro", "name": "industries_intro", "type": "wysiwyg", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "tabs": "all", "toolbar": "basic", "media_upload": 0, "delay": 0 }, { "key": "field_5aafec5245ef3", "label": "Why Amarinth?", "name": "", "type": "tab", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "placement": "top", "endpoint": 0 }, { "key": "field_5aafec5d45ef4", "label": "Why Amarinth Intro", "name": "why_amarinth_intro", "type": "textarea", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "default_value": "", "placeholder": "", "maxlength": 500, "rows": 3, "new_lines": "" }, { "key": "field_5ae9993992d78", "label": "Why Amarinth Key Intro", "name": "why_amarinth_key_intro", "type": "wysiwyg", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "tabs": "all", "toolbar": "basic", "media_upload": 0, "delay": 0 }, { "key": "field_5aafec9245ef5", "label": "Why Amarinth Key Points", "name": "why_amarinth_key_points", "type": "wysiwyg", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "default_value": "", "tabs": "all", "toolbar": "basic", "media_upload": 0, "delay": 0 }, { "key": "field_5aafecc145ef6", "label": "Why Amarinth Testimonials", "name": "why_amarinth_testimonials", "type": "repeater", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "collapsed": "", "min": 0, "max": 0, "layout": "block", "button_label": "Add Client Quote", "sub_fields": [ { "key": "field_5aafecd645ef7", "label": "Client Says", "name": "client_says", "type": "textarea", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "70", "class": "", "id": "" }, "default_value": "", "placeholder": "", "maxlength": 1000, "rows": 3, "new_lines": "" }, { "key": "field_5aafed1545ef8", "label": "Client Name", "name": "client_name", "type": "text", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5aafed2c45ef9", "label": "Client Job Role", "name": "client_job_role", "type": "text", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5aafed4145efa", "label": "Client Company", "name": "client_company", "type": "text", "instructions": "", "required": 1, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5aafed4e45efb", "label": "Company Logo", "name": "client_image", "type": "image", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "25", "class": "", "id": "" }, "return_format": "id", "preview_size": "thumbnail", "library": "all", "min_width": "", "min_height": "", "min_size": "", "max_width": "", "max_height": "", "max_size": "", "mime_types": "" } ] }, { "key": "field_5aafef1ddd410", "label": "Experience", "name": "", "type": "tab", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "placement": "top", "endpoint": 0 }, { "key": "field_5ab013d5b83ec", "label": "Experience By Client", "name": "exp_by_client", "type": "repeater", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "collapsed": "", "min": 0, "max": 0, "layout": "row", "button_label": "Add New Experience Group", "sub_fields": [ { "key": "field_5ad4f5bfd9d1e", "label": "Choose Experience Type", "name": "choose_experience_type", "type": "radio", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "choices": { "End Client": "End Client", "Contractor": "Contractor" }, "allow_null": 0, "other_choice": 0, "save_other_choice": 0, "default_value": "", "layout": "horizontal", "return_format": "value" }, { "key": "field_5ad4fe42d9d1f", "label": "Select End User", "name": "select_end_user", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": [ [ { "field": "field_5ad4f5bfd9d1e", "operator": "==", "value": "End Client" } ] ], "wrapper": { "width": "", "class": "", "id": "" }, "taxonomy": "doc-client", "field_type": "select", "allow_null": 1, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad4febcd9d20", "label": "Select Contractor", "name": "select_contractor", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": [ [ { "field": "field_5ad4f5bfd9d1e", "operator": "==", "value": "Contractor" } ] ], "wrapper": { "width": "", "class": "", "id": "" }, "taxonomy": "doc-contractor", "field_type": "select", "allow_null": 1, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5b0544f908f35", "label": "End User \/ Contractor Logo", "name": "end_user_contractor_logo", "type": "image", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "return_format": "array", "preview_size": "thumbnail", "library": "all", "min_width": "", "min_height": "", "min_size": "", "max_width": "", "max_height": "", "max_size": "", "mime_types": "" }, { "key": "field_5ad4ff1838e57", "label": "Add New Experience", "name": "add_new_experience", "type": "repeater", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "collapsed": "", "min": 0, "max": 0, "layout": "block", "button_label": "Add New Project", "sub_fields": [ { "key": "field_5ad4ff5538e58", "label": "End User", "name": "exp_end_user", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": [ [ { "field": "field_5ad4f5bfd9d1e", "operator": "==", "value": "Contractor" } ] ], "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "doc-client", "field_type": "select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad4ff9638e59", "label": "Main Contractor", "name": "exp_main_contractor", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": [ [ { "field": "field_5ad4f5bfd9d1e", "operator": "==", "value": "End Client" } ] ], "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "doc-contractor", "field_type": "select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad4ffcb38e5a", "label": "Project Name", "name": "exp_project_name", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "doc-project-name", "field_type": "select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad5004f38e5b", "label": "Project Site", "name": "exp_project_site", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "doc-site-location", "field_type": "select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad5150069ecc", "label": "Application", "name": "exp_project_application", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "application", "field_type": "multi_select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad5154f69ecd", "label": "Product Supplied", "name": "exp_project_product_supplied", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5ad5157669ece", "label": "Materials", "name": "exp_project_materials", "type": "text", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "default_value": "", "placeholder": "", "prepend": "", "append": "", "maxlength": "" }, { "key": "field_5ad5158869ecf", "label": "Standards", "name": "exp_project_standards", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "designstandard", "field_type": "multi_select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad515ab69ed0", "label": "Customer Specifications", "name": "exp_project_specifications", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "taxonomy": "doc-customer-spec", "field_type": "multi_select", "allow_null": 0, "add_term": 1, "save_terms": 0, "load_terms": 0, "return_format": "object", "multiple": 0 }, { "key": "field_5ad5160169ed1", "label": "Publication", "name": "exp_project_publication", "type": "page_link", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "33.33", "class": "", "id": "" }, "post_type": [ "pnm-post" ], "taxonomy": [ "category:case-studies", "category:press-releases" ], "allow_null": 0, "allow_archives": 1, "multiple": 0 } ] } ] }, { "key": "field_5aafef2cdd411", "label": "Msg", "name": "", "type": "message", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "message": "This data entry element is coming in due course.", "new_lines": "", "esc_html": 0 }, { "key": "field_5aafefcd7f4ba", "label": "Applications", "name": "", "type": "tab", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "placement": "top", "endpoint": 0 }, { "key": "field_5aafefda7f4bb", "label": "Applications Intro", "name": "applications_intro", "type": "textarea", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "default_value": "", "placeholder": "", "maxlength": 600, "rows": "", "new_lines": "wpautop" }, { "key": "field_5aaff0aa7f4bc", "label": "Industry Specific Applications", "name": "industry_specific_applications", "type": "taxonomy", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "50", "class": "", "id": "" }, "taxonomy": "application", "field_type": "multi_select", "allow_null": 0, "add_term": 1, "save_terms": 1, "load_terms": 1, "return_format": "object", "multiple": 0 }, { "key": "field_5aaff0d87f4bd", "label": "Related Products", "name": "", "type": "tab", "instructions": "", "required": 0, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "placement": "top", "endpoint": 0 }, { "key": "field_5ab02bbdc6179", "label": "Related Products", "name": "related_products", "type": "relationship", "instructions": "This is currently just a test as it will be possible to automatically include these pages via the main industry taxonomy term, however this currently pull in the intermediate pages too. This can be fixed after a discussion on how we tag industry taxonomy and on which pages.", "required": 1, "conditional_logic": 0, "wrapper": { "width": "", "class": "", "id": "" }, "post_type": [ "page" ], "taxonomy": [ "category:products-page" ], "filters": [ "search" ], "elements": "", "min": "", "max": "", "return_format": "object" } ], "location": [ [ { "param": "post_type", "operator": "==", "value": "page" }, { "param": "post_template", "operator": "==", "value": "template-industries.php" } ] ], "menu_order": 0, "position": "acf_after_title", "style": "default", "label_placement": "top", "instruction_placement": "label", "hide_on_screen": [ "the_content", "excerpt", "discussion", "comments", "revisions", "author", "format", "featured_image", "send-trackbacks" ], "active": 1, "description": "" } ]

Technical info