Make WordPress Core

Opened 4 weeks ago

Last modified 4 weeks ago

#62360 assigned defect (bug)

Child category lost indention (margin-left) when it's checked but its parent not checked

Reported by: unicornboat's profile unicornboat Owned by:
Milestone: Awaiting Review Priority: normal
Severity: trivial Version: 6.6.2
Component: Taxonomy Keywords: close
Focuses: Cc:

Description

How to replicate:

  • have two categories: 1 parent and 1 child
  • create a new post. the child category is indented because it's in the <ul> under its parent
  • check the child category then save
  • after page refreshed. the selected child category lost its indention because it's placed at the at level with its parent in the same <ul>

Change History (4)

#1 @ankitkumarshah
4 weeks ago

Hi @unicornboat,

Thank you for highlighting this issue.

I’ve tried to replicate it with the following steps:

  1. Created two categories: one as a parent and one as a child.
  2. Created a new post and selected the child category.
  3. Saved the post.

After refreshing, my page appears as shown below:
https://postimg.cc/gwPFhx7Q

For reference, I’m using WordPress version 6.6.2.

Let me know if there are any additional steps I might have missed. Thanks again for your help!

#2 @unicornboat
4 weeks ago

Thanks for testing. I realised that the editor in your test is the block editor and the issue happens when using classic editor. When I switch to the block mode, the issue is gone.

#3 @ankitkumarshah
4 weeks ago

Hi @unicornboat,

Thank you so much for providing the additional details. I was able to successfully reproduce the issue you described.

https://postimg.cc/t1KC5fdJ

After conducting some research and reviewing the core code, I discovered that this behavior is intentional. If you’d like the indentation to remain persistent, you might consider using the wp_terms_checklist_args filter.

Here is a code snippet that demonstrates how you can achieve this:

add_filter('wp_terms_checklist_args', 'modify_category');

function modify_category($args) {
    $args['checked_ontop'] = false;
    return $args;
}

Result:
https://postimg.cc/WhmVLzG2

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

#4 @unicornboat
4 weeks ago

  • Keywords close added; needs-patch removed

Thank you @ankitkumarshah
Your snippet solved my problem. I didn't know it was designed intentional but anyway it's always great to have options for people who want to keep things the old way.

Note: See TracTickets for help on using tickets.