Make WordPress Core

Opened 21 months ago

Last modified 4 months ago

#26268 assigned enhancement

Add UI to Category page to indicate default category

Reported by: kraftbj Owned by: seanchayes
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: good-first-bug has-patch ux-feedback
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 (17)

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

Download all attachments as: .zip

Change History (48)

comment:1 @SergeyBiryukov21 months ago

  • Keywords needs-ui added

comment:2 @helen19 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.

comment:3 @paulwilde19 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 19 months ago by paulwilde (previous) (diff)

comment:4 @nacin19 months ago

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

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

comment:5 @ircbot19 months ago

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

comment:6 @kraftbj19 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.

@kraftbj19 months ago

Refreshed version of paulwilde's patch

comment:7 @helen19 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.

comment:8 @kraftbj16 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 16 months ago by kraftbj (previous) (diff)

comment:9 @seanchayes16 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.

@seanchayes16 months ago

comment:10 @kraftbj16 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.

comment:11 @keita_kobayashi15 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 .

@keita_kobayashi15 months ago

Wraps the (default) in for i18n

comment:12 @kraftbj15 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.

comment:13 @ircbot14 months ago

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

comment:14 @helen14 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?

comment:15 @seanchayes14 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.

@seanchayes14 months ago

@seanchayes14 months ago

comment:16 @ircbot11 months ago

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

@wonderboymusic11 months ago

comment:17 @wonderboymusic11 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

comment:18 @DrewAPicture11 months ago

  • Owner changed from paulwilde to seanchayes

comment:19 @helen11 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.

comment:20 @kraftbj11 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?

comment:21 @seanchayes11 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)

@seanchayes11 months ago

comment:22 @DrewAPicture11 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.

comment:23 @kraftbj11 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).

comment:24 @seanchayes10 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.

comment:25 @kraftbj10 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.

@kraftbj10 months ago

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

comment:26 @seanchayes10 months ago

Ugh - thanks and apologies.

comment:27 @slackbot10 months ago

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

comment:28 @slackbot10 months ago

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

comment:29 @johnbillion9 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?

comment:30 @kraftbj6 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

@kraftbj6 months ago

26268.7 with the CSS and UI to change default removed.

@kraftbj6 months ago

26268.8 without the bad intent on one line :)

comment:31 @slackbot4 months ago

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

Note: See TracTickets for help on using tickets.