#62440 closed defect (bug) (fixed)
"Most Used" Category Tabs Not Synced with "All Categories" Tab in Classic Editor
Reported by: | charleslf | Owned by: | azaozz |
---|---|---|---|
Milestone: | 6.7.1 | Priority: | normal |
Severity: | normal | Version: | 6.7 |
Component: | Editor | Keywords: | has-patch needs-testing fixed-major commit dev-reviewed |
Focuses: | Cc: |
Description
Description
When using the Classic Editor, the "Most Used" category tabs are not properly synced with the "All Categories" tab. This issue appears to have been introduced after the fix for #61014(https://core.trac.wordpress.org/ticket/61014), as the code block in post.js
does not reflect the updated ID structure.
Steps to Reproduce
# Go to the "Posts" section in the WordPress admin panel.
# Add or edit a post.
# Open the "Categories" meta box.
# Notice that when selecting categories from the "All Categories" tab, the selections do not update the "Most Used" tab, and vice versa.
# This behavior occurs when the Classic Editor is enabled.
Expected Behavior
The "Most Used" category tab should automatically sync with the "All Categories" tab, maintaining consistency between the two views.
Actual Behavior
The "Most Used" category tab is not updated when categories are selected or deselected in the "All Categories" tab.
Code Analysis
The bug appears to be related to the following block of code in post.js
:
// Sync checked items between "All {taxonomy}" and "Most used" lists. $('#' + taxonomy + 'checklist, #' + taxonomy + 'checklist-pop').on( 'click', 'li.popular-category > label input[type="checkbox"]', function() { var t = $(this), c = t.is(':checked'), id = t.val(); if ( id && t.parents('#taxonomy-'+taxonomy).length ) $('#in-' + taxonomy + '-' + id + ', #in-popular-' + taxonomy + '-' + id).prop( 'checked', c ); } );
This block does not seem to account for the changed ID structure introduced in the fix for #61014(https://core.trac.wordpress.org/ticket/61014), causing the syncing issue between the two category tabs.
Attachments (1)
Change History (21)
#2
@
3 weeks ago
Hello @im3dabasia1,
The steps that I followed are:
- Enter the "Add New Post" page
- Select the "Most Used" tab
- Check any category
- Switch back to the "All Categories" tab. No category will be checked.
- If the post is published, it will be Uncategorized.
Here is a recording to better illustrate the issue: https://streamable.com/jg725h
#3
@
3 weeks ago
Hello @charleslf,
Thank you for clarifying! You’re correct—I was able to reproduce the issue, and it does indeed appear to be a bug.
Additionally, while testing, I noticed another related issue:
- Navigate to the "Add New Post" page.
- Select the "Most Used" tab in the Categories section.
- Check any category.
- Save or update the post.
- Upon reviewing the Categories section, the category selected in step 3 does not remain checked, neither in the "Most Used" tab nor in "All Categories."
This ticket was mentioned in PR #7810 on WordPress/wordpress-develop by @im3dabasia1.
3 weeks ago
#4
- Keywords has-patch added
Trac ticket:https://core.trac.wordpress.org/ticket/62440
### Description:
This PR addresses a bug where the "Most Used" category tab was not synced with the "All Categories" tab in the Classic Editor. When selecting categories in the "Most Used" tab, the changes were not reflected in the "All Categories" tab, causing inconsistency in category selection.
### Fix:
- Added functionality to ensure the category selection in the "Most Used" tab correctly updates the "All Categories" tab.
- Updated the event listeners to ensure proper syncing of checkbox states between the two tabs.
- The issue occurred because the 'All Categories' section had a suffix appended to it, as shown in the screenshot below.
### Steps to Test:
- Open the Classic Editor in WordPress.
- Go to the "Categories" section.
- Select a category from the Most used section.
- Notice that the category won't be checked in the "All categories" section.
- Their is No sync between categories checked in the "Most used" section and "All categories" section
### Video demonstration
Before:
https://github.com/user-attachments/assets/1f2975ba-12e8-47f1-b9ec-671325dbf6ea
After:
https://github.com/user-attachments/assets/0830a5a3-67e8-4131-8b1d-406adc5fcf8d
This ticket was mentioned in Slack in #core by desrosj. View the logs.
3 weeks ago
#6
@
3 weeks ago
- Component changed from General to Editor
- Milestone changed from Awaiting Review to 6.7.1
3 weeks ago
#7
Hi @im3dabasia, thanks for the patch. Seems to work well here.
This is a super old JS. Pushed couple of small changes: limit it only to input
elements as it was matching li
too, also shortened it a bit. Please see if it still works well. This seems to also work with the previous HTML IDs so if someone is using a custom walker class, it won't break.
#8
@
3 weeks ago
- Keywords needs-testing added
There are several reports that seem related. Changes to the selected categories not being saved when using the classic editor.
I can reproduce both types of errors and the PR seems to work well here. Thinking this will be good for 6.7.1 after a bit more testing.
@im3dabasia1 commented on PR #7810:
3 weeks ago
#10
Hi @im3dabasia, thanks for the patch. Seems to work well here. This is a super old JS. Pushed couple of small changes: limit it only to
input
elements as it was matchingli
too, also shortened it a bit. Please see if it still works well. This seems to also work with the previous HTML IDs so if someone is using a custom walker class, it won't break.
I tested it, and it works as expected. Thanks for the updates!
#11
@
3 weeks ago
Test Report
Description
This report validates that this patch syncs the most used categories and categories tab selection.
Patch tested: https://patch-diff.githubusercontent.com/raw/WordPress/wordpress-develop/pull/7810.diff
Environment
- WordPress: 6.8-alpha-59274-src
- PHP: 8.2.22
- Server: nginx/1.27.0
- Database: mysqli (Server: 8.0.39 / Client: mysqlnd 8.2.22)
- Browser: Chrome 128.0.0.0
- OS: Linux
- Theme: Twenty Twenty-Five 1.0
- MU Plugins: None activated
- Plugins:
- Test Reports 1.2.0
Actual Results
- ✅ Issue resolved with patch.
Supplemental Artifacts
Added as Attachment
#12
@
3 weeks ago
- Owner set to azaozz
- Resolution set to fixed
- Status changed from new to closed
In 59414:
#13
@
3 weeks ago
- Keywords fixed-major added
- Resolution fixed deleted
- Status changed from closed to reopened
Reopening to consider backporting.
#14
@
3 weeks ago
- Keywords commit dev-reviewed added
Thanks everyone, looks good and tests good for me. Going to backport.
#17
in reply to:
↑ 16
@
2 weeks ago
Having this exact same issue. It seems to happen when selecting a category with an ID that starts with the same number as other categories. For example, selecting the category #in-category-5-2 any other category that starts with 5 is also selected, for example #in-category-50-2, #in-category-51-2, #in-category-58-2 etc.
Replying to creatis:
Version 6.7.1
Multiple checkboxes can now be set instead of one selected checkbox.
In the screenshot, I clicked on Full Time. The Contract checkbox was set by itself.
There is no problem in the “Most Used” tab. The checkboxes are in the WP Job Manager plugin.
#18
follow-up:
↓ 19
@
13 days ago
@powerbuoy your issue might be related to https://core.trac.wordpress.org/ticket/62504
#19
in reply to:
↑ 18
@
13 days ago
Yea, that seems to be the same issue.
Replying to dhruvang21:
@powerbuoy your issue might be related to https://core.trac.wordpress.org/ticket/62504
Hi @charleslf,
Thank you for raising this ticket. I attempted to reproduce the issue but found that the "Most Used" categories section appears to be working as expected.
Here’s what I tested:
I have recorded my test for reference: https://jumpshare.com/s/G6jhPLHR7F1JVLYLFkqK
Please let me know if I might have missed any specific steps or scenarios that could help in reproducing the issue. Thank you