Make WordPress Core

Opened 7 weeks ago

Closed 7 weeks ago

Last modified 6 days ago

#62599 closed defect (bug) (duplicate)

Bug in Category Checklist: Selecting a Category Auto-Selects Others in Post Editor

Reported by: patrikmuse's profile patrikmuse Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.7.1
Component: General Keywords: needs-patch
Focuses: javascript Cc:

Description

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:

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:

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

Change History (3)

#1 follow-up: @ankitkumarshah
7 weeks ago

Hi @patrikmuse,

Thank you for bringing this up. Could you please take a look at issue #62504 and let me know if it resolves your issue?

Last edited 7 weeks ago by ankitkumarshah (previous) (diff)

#2 in reply to: ↑ 1 @patrikmuse
7 weeks ago

  • Resolution set to duplicate
  • Status changed from new to closed

Replying to ankitkumarshah:

Hi @patrikmuse,

Thank you for bringing this up. Could you please take a look at issue #62504 and let me know if it resolves your issue?


Ahh!! Yes, same bug, thanks a lot ankitkumarshah

#3 @desrosj
6 days ago

  • Milestone Awaiting Review deleted
Note: See TracTickets for help on using tickets.