Bug Report: “cmb2-conditionals.js” Causes WordPress Menu Items to Disappear
-
Hi,
I have encountered a critical issue with the Custom Product Type for WooCommerce plugin, specifically with the cmb2-conditionals.js file.?? Issue Description:
When using the WordPress menu management screen (Appearance > Menus):
- I create a new menu and add menu items.
- After saving, the menu items appear in the AJAX response correctly.
- However, when the page reloads, all the menu items disappear from the UI.
The issue is traced back to the cmb2-conditionals.js:178 script, specifically this block:
for ( loopI = 0; loopI < uniqueFormElms.length; loopI++ ) { formElms = $( '[name="' + uniqueFormElms[loopI] + '"]' ); if ( 1 === formElms.length || ! formElms.is( ':checked' ) ) { formElms.trigger( 'change' ); } else { formElms.filter( ':checked' ).trigger( 'change' ); } }
When I remove this part, the issue disappears. It seems that triggering
change
is resetting or hiding the menu items unexpectedly.?? Debugging Details:
- The menu items are saved in the database correctly.
- The AJAX response contains the correct menu items after saving.
- No errors appear in the console or debug log.
- Disabling the cmb2-conditionals.js script on the menu page fixes the issue.
?? Possible Fix Suggestions:
- Exclude cmb2-conditionals.js from running on the menu page (
nav-menus.php
). - Review the
change
event triggers and how they affect non-CMB2 related inputs. - Provide a filter or option to disable conditionals in certain admin pages.
Could you please investigate this and provide a fix in the next update?
Thanks for your time and for maintaining this plugin! ??
- You must be logged in to reply to this topic.