Make WordPress Core

Opened 2 years ago

Last modified 4 weeks ago

#26268 reviewing enhancement

Add UI to Category page to indicate default category

Reported by: kraftbj Owned by: helen
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: good-first-bug has-patch ux-feedback needs-testing
Focuses: ui, administration Cc:


Currently, the default category is set in Settings->Writing and it only indicated on the Category page (Posts->Categories) via the lack of a checkbox to delete.

  1. Add a visual indicator on the Categories page to indicate the default category.
  2. Add an option to change the default on the Categories page.

Attachments (19)

default-taxonomy.diff (3.9 KB) - added by paulwilde 22 months ago.
26268.diff (3.9 KB) - added by kraftbj 22 months ago.
Refreshed version of paulwilde's patch
26268.2.diff (6.0 KB) - added by kraftbj 19 months ago.
Updated per https://core.trac.wordpress.org/ticket/26268#comment:8
26268.3.diff (6.1 KB) - added by seanchayes 19 months ago.
26268.show.default.diff (7.0 KB) - added by keita_kobayashi 18 months ago.
26268.show-default-i18nfix.diff (7.0 KB) - added by keita_kobayashi 18 months ago.
Wraps the (default) in for i18n
26268.4.diff (6.6 KB) - added by seanchayes 17 months ago.
26268.4.jpg (76.5 KB) - added by seanchayes 17 months ago.
26268.5.diff (5.9 KB) - added by wonderboymusic 14 months ago.
26268.6.diff (8.3 KB) - added by seanchayes 13 months ago.
26268-default-category-in-list-at-top-01.jpg (108.2 KB) - added by seanchayes 13 months ago.
26268-default-category-in-list-at-top-02.jpg (107.9 KB) - added by seanchayes 13 months ago.
26268-default-category-in-list-at-top-03.jpg (99.5 KB) - added by seanchayes 13 months ago.
row_actions_hover.png (42.1 KB) - added by DrewAPicture 13 months ago.
26268.7.diff (7.8 KB) - added by kraftbj 13 months ago.
Same as .6, minus the user-edit.php revision.
26268.8.diff (3.4 KB) - added by kraftbj 9 months ago.
26268.7 with the CSS and UI to change default removed.
26268.9.diff (3.3 KB) - added by kraftbj 9 months ago.
26268.8 without the bad intent on one line :)
26268.10.diff (3.2 KB) - added by seanchayes 3 months ago.
26268.11.diff (3.2 KB) - added by wonderboymusic 2 months ago.

Download all attachments as: .zip

Change History (55)

#1 @SergeyBiryukov
2 years ago

  • Keywords needs-ui added

#2 @helen
22 months ago

  • Focuses ui added
  • Keywords good-first-bug added; needs-ui removed
  • Milestone changed from Awaiting Review to Future Release

I like this. Possibly with the word "Default" next to the term name in the list table (the way Sticky shows in the posts list table) and another row action to "Set as Default". Probably needs some thought about the individual edit term screen.

I would then add 3. Remove from Settings -> Writing.

#3 @paulwilde
22 months ago

  • Keywords has-patch added

Created a patch which will do the following:

  • Adds a "Default" label in the same style as Sticky/Draft shows in the post rows.
  • Adds an action titled "Set as Default" if the user has permission to manage options which sets the default taxonomy. This is limited to only show for the category taxonomy, but could be abstracted in future should other taxonomies need the ability to have a default.
  • Removes the Default Category setting from Settings -> Writing.
Last edited 22 months ago by paulwilde (previous) (diff)

#4 @nacin
22 months ago

  • Owner set to paulwilde
  • Status changed from new to assigned

Nice, paulwilde! We'll get someone to review this.

This ticket was mentioned in IRC in #wordpress-dev by nacin. View the logs.

22 months ago

#6 @kraftbj
22 months ago

This works for me. Patch is stale for /wp-admin/includes/class-wp-terms-list-table.php, so attaching an updated one. No changes to the patch itself.

22 months ago

Refreshed version of paulwilde's patch

#7 @helen
22 months ago

  • Keywords ux-feedback added

Thanks for the patch, paulwilde, and thanks for refreshing, kraftbj. It's working great, and I like how it feels. There are a few things it's exposing to me at the moment:

  • After you set the default, you get redirected back to the first page of the list table, rather than the one you were on. Editing a term does return you to the appropriate page.
  • We need an updated message at the top letting the user know the action was successful.
  • We should probably do the same thing for link categories - the UI for links is hidden in new installs, but when it is shown, it would be nice to use the same paradigm.
  • We should probably set the "Set as Default" string to not wrap (CSS).

Going to try running this shift by jenmylo for a UX check as well.

#8 @kraftbj
19 months ago

Taking @paulwilde's initial patch and adding in the suggestions by Helen, particularly:

  • Updated the redirect URL to included a paged query arg to redirect back to initial page.
  • Added a message indicating Category default was set. Though unused, added similar messages to the other cases to keep the arrays consistent.
  • Duplicated the work for Links (including it in the conditional for displaying the Set as Default and removing the default from Settings->Writing)
  • Set CSS to nowrap the line, and removed the nbsp from Quick Edit in the same set of action items for consistency.

Additionally, I added a nonce check for it, just to be safe.

Last edited 19 months ago by kraftbj (previous) (diff)

#9 @seanchayes
19 months ago

I found this patch worked really well. I also found that it was being applied to Tags or non-hierarchical taxonomies. For example, with the 26268.2 patch I found I could set a tag as default and then I couldn't remove it.

So I have the following modified patch:

26268.3 - this modifies the "Is this the Category or Link Category" check so that the "Set as Default" option is only active on the Category admin page.

19 months ago

#10 @kraftbj
19 months ago

Thanks for catching that. I had it working right, but must have changed it up and not properly tested it.

Confirmed that .2 is deficient as stated and .3 resolves it.

#11 @keita_kobayashi
18 months ago

I really like this new UI, but realized that the user may not remember which category was set as default when authoring a new post. I'm not sure this is in the scope of this patch, but maybe having a "(default)" will remind the user that that category will be automatically applied if no other category is manually selected? I've attached a simple implementation of this in 26268.show.default.diff .

18 months ago

Wraps the (default) in for i18n

#12 @kraftbj
18 months ago

@keita_kobayashi: I don't know if it is within the scope of the ticket or not, but it's a nice touch :-)

My thoughts on that piece:

  1. What about, in addition to the label, on a new post it is outputted first? e.g.

Category 1 (default)

  1. When editing an existing post, does the user care what the default category is? Does the label still need to be there?

I defer to the core developers on if this should be part of this ticket or figured out before deciding on the rest of the patch.

This ticket was mentioned in IRC in #wordpress-dev by kraftbj. View the logs.

17 months ago

#14 @helen
17 months ago

26268.3.diff works well, looks good at a glance. It exposes something to me though - you can't quickly get an idea which category is your default if you have lots of them. What could be done there? Possibly show the default at the top of the list?

#15 @seanchayes
17 months ago

I've updated the patch - now 26268.4.diff - so it displays the default category above the table list of categories. This allows the default category to persist in display when navigating through the category list.

I have also added a screenshot of how it looks.

17 months ago

17 months ago

This ticket was mentioned in IRC in #wordpress-dev by kraftbj. View the logs.

14 months ago

#17 @wonderboymusic
14 months ago

  • Milestone changed from Future Release to 4.1

26268.5.diff accounts for [29782] - this seems like a good enhancement for 4.1

#18 @DrewAPicture
14 months ago

  • Owner changed from paulwilde to seanchayes

#19 @helen
14 months ago

What are the chances we can float the default term to the top of the list? I have a feeling it might not be pretty, given paging.

#20 @kraftbj
14 months ago

@helen: First glance, not pretty.

What is your thinking behind floating it to the top? Add visibility? Quicker to find to edit? Would linking the "Default Category: X" text added in 26268.4.diff to the edit terms page meet the objective?

#21 @seanchayes
13 months ago

I took 26268.5.diff and added the idea from comment:19.

I've applied the code changes into 26268.6.diff and uploaded three images showing how I interpreted that comment.

The default category shows at the top of the list :

  • The first time the list is displayed. (image 1)
  • For times when the category list is processed for paging. (image 2)
  • When a column is chosen as the column to sort on including when paged. (image 2)
  • When a search is performed using "Search Categories" (image 3)

13 months ago

#22 @DrewAPicture
13 months ago

Just a couple of things that jumped out at me about 26268.6.diff:

  • We probably need a more specific selector on nowrap-ing the 'Set to Default' string, .row-actions a is pretty global and could have more far-reaching effects elsewhere in the admin
  • Something else wasn't really well-illustrated in the screenshots is that row actions are now forced to two lines because of the width of the column (see row_actions_hover.png). At first I figured the row actions count was off because the separator was on the end of the line but then I realized it was wrapping

I kind of wonder if maybe instead of trying to add a seldom-used action link to the row actions, perhaps that might be a better fit in edit-tags and/or quick edit.

#23 @kraftbj
13 months ago

@seanchayes - As confirmation, did the user-edit.php diff slide in my mistake in 26268.6.diff ?


  • We could argue that the .row-actions a is a good idea either way since having a line break within a link in row actions is poor UI. May be better discussed in a separate ticket, though, since it would impact more than this and/or more specific selector.
  • The two-line doesn't concern me, in and of itself. It is already two lines on thinner viewports (~<1300px).

#24 @seanchayes
13 months ago

@kraftbj - did I lose some code that you provided? I'm not sure I recall any changes to user-edit.php? Sorry. I pulled down 26268.5 and then created .6 from that. So I hope I've not messed anything up.

I'm thinking that the ability to set the default category at anytime whilst browsing through the category list is useful. I do also agree it's a seldom used option (comment:22), but it is now in a more logical place and with a visual cue compared to where it was before this patch.

As @kraftbj says, forcing the action text to display on two lines does already occur.

#25 @kraftbj
13 months ago

@seanchayes - On the contrary, looks like extra changes were added in 26268.6.diff (see the end of the patch). Maybe testing out another patch and hadn't svn revert -R .?

In either event, refreshing the patch.

13 months ago

Same as .6, minus the user-edit.php revision.

#26 @seanchayes
13 months ago

Ugh - thanks and apologies.

This ticket was mentioned in Slack in #core by kraft. View the logs.

13 months ago

This ticket was mentioned in Slack in #core by kraft. View the logs.

13 months ago

#29 @johnbillion
12 months ago

  • Milestone changed from 4.1 to Future Release

Adding a "Set as default" link to every row seems like a lot of unnecessary visual noise. How often do you change the default term for a given taxonomy?

#30 @kraftbj
9 months ago

  • Focuses administration added

Chatted with @helen in Slack: https://wordpress.slack.com/archives/core/p1424923581006944

Where we're at now is we're trying to push too much in this one ticket.

This ticket will focus exclusively on the UI for indicating the default category, which should be a quicker win for users.

The CSS change I'm dropping completely. Checking /wp-admin/ more, using a &nbsp; is what is used elsewhere (with the exception of #31482) and provides the same benefit.

The UI for *changing* default category will be discussed in #31483

9 months ago

26268.7 with the CSS and UI to change default removed.

9 months ago

26268.8 without the bad intent on one line :)

This ticket was mentioned in Slack in #core by kraft. View the logs.

7 months ago

#32 @seanchayes
3 months ago

  • Keywords needs-testing added

In the spirit of Trac Gardening I've refreshed this patch. It:

  1. Displays the default category as the 1st item in the list table regardless of the page number / count in the list. It is also annotated "- default"
  2. As @kraftbj said in comment:20 the UI for changing the default category is not included in this patch.
  3. It reflects the screenshots in between comment:21 and comment:22
  4. I changed the default category a couple of times and sure enough the newly changed default showed up at the top of the list table.

Testing welcome / required.

#33 @chriscct7
3 months ago

@seanchayes that's the spirit! Unfortunately, it looks like your patch didn't upload. Can you try uploading it again please? Thanks!

3 months ago

#34 @kraftbj
3 months ago

.10 works well in testing. It stuck the default at the top of the list table and remained there as I advanced to addition pages of categories.

One edge case: If the default category is a child category.
Previously: It would be shown as a child category (without the checkbox to delete and without the delete option).
.10: It remains at the top of the list table with no difference in appearance compared to a top-level category.

Do we need to preserve the visual indication of a child category on edit-tags.php?taxonomy=category?

#35 @wonderboymusic
2 months ago

  • Owner changed from seanchayes to helen
  • Status changed from assigned to reviewing

26268.11.diff - would lurve your eyes on this

#36 @tzon
4 weeks ago

I added the patch 12684 that added an edit btn for bulk actions for categories. I added some categories at 3 levels of parenthood. All looked well. I then added this patch to show default category. It showed the default but then did not list the child categories I added previously. I'm not sure why.

Note: See TracTickets for help on using tickets.