[wp-trac] [WordPress Trac] #62599: Bug in Category Checklist: Selecting a Category Auto-Selects Others in Post Editor

WordPress Trac noreply at wordpress.org
Thu Nov 28 11:10:43 UTC 2024


#62599: Bug in Category Checklist: Selecting a Category Auto-Selects Others in Post
Editor
--------------------------+-----------------------------
 Reporter:  patrikmuse    |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  6.7.1
 Severity:  normal        |   Keywords:  needs-patch
  Focuses:  javascript    |
--------------------------+-----------------------------
 **Description:**
 In the WordPress post editor, when selecting a category in the
 "Categories" meta box (under "All Categories"), other unrelated categories
 are also auto-selected. This issue occurs inconsistently and seems to
 involve categories marked as "popular-category" in the DOM structure.

 **Steps to Reproduce:**
 Open the post editor in WordPress (e.g., wp-
 admin/post.php?post=[POST_ID]&action=edit).
 Scroll to the "Categories" meta box.
 Select a category from the "All Categories" list.
 Observe that other unrelated categories in the same list are also auto-
 selected.
 **Expected Behavior:**
 When a category is selected, only that specific category should be
 selected, without affecting any others.
 **Observed Behavior:**
 Selecting a category in the "All Categories" list automatically selects
 other unrelated categories. The issue appears to involve categories that
 have the class popular-category.


 **Script Involved: post.min.js?ver=6.7.1**
 Specifically, the following function seems to be responsible for the
 unintended behavior:

 {{{#!php
 h("#"+a+"checklist, #"+a+"checklist-pop").on("click", 'li.popular-category
 > label input[type="checkbox"]', function() {
     var t=h(this),
         e=t.is(":checked"),
         i=t.val();
     i && t.parents("#taxonomy-"+a).length && (
         h('input[id^="in-'+a+"-"+i+'"]').prop("checked", e),
         h("input#in-popular-"+a+"-"+i).prop("checked", e)
     )
 });
 }}}


 **Temporary Workaround:**
 Adding the following custom script disables the conflicting event and
 resolves the issue temporarily:

 {{{#!php
 (function($) {
     $(document).ready(function() {
         $('#categorychecklist input[type="checkbox"]').off('click');
     });
 })(jQuery);

 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/62599>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list