Make WordPress Core

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#43743 closed defect (bug) (fixed)

Terms list table should be full width when user cannot edit terms

Reported by: swissspidy's profile swissspidy Owned by: mathieuhays's profile mathieuhays
Milestone: 5.1 Priority: normal
Severity: minor Version:
Component: Taxonomy Keywords: has-screenshots good-first-bug ui-feedback has-patch dev-feedback
Focuses: administration Cc:

Description

The edit-tags.php screen is split into two columns. On the left hand side is a form to create new terms, on the right hand side is the list of existing terms.

Now, the form is only visible if the user has the edit_terms capability for the current taxonomy. If they don't, the left column is simply empty.

Instead of wasting this space, I'd suggest to make the list table take the full width of the screen instead of residing at the right side.

Unfortunately this can't be yet achieved using CSS alone because #col-left isn't empty as it contains a .col-wrap div.

If we'd move the current_user_can( $tax->cap->edit_terms ) check outside .col-wrap or even #col-left, we could use something like #col-left:empty #col-right { float: none; width: 100% }

Attachments (4)

list-table-float-right.png (84.6 KB) - added by swissspidy 7 years ago.
Status quo
list-table-float-none.png (91.4 KB) - added by swissspidy 7 years ago.
Proposed solution
43743.diff (1.0 KB) - added by mathieuhays 7 years ago.
43743.2.diff (1.1 KB) - added by swissspidy 6 years ago.

Download all attachments as: .zip

Change History (14)

@swissspidy
7 years ago

Status quo

@swissspidy
7 years ago

Proposed solution

#1 @swissspidy
7 years ago

  • Keywords needs-patch good-first-bug ui-feedback added

#2 @danieltj
7 years ago

I'd suggest hiding the div completely (not using CSS) if it's empty so it's not present in the DOM as it doesn't need to exist on the page if empty. What scenario allows you to access this page but not add new terms? What role do you need to have/setup to test this?

#3 @swissspidy
7 years ago

What scenario allows you to access this page but not add new terms? What role do you need to have/setup to test this?

This happens when you have the manage_terms capability for that taxonomy but not edit_terms.

In my case, the custom taxonomy was registered with caps like these:

'capabilities'          => [
        'manage_terms' => 'manage_categories',
        'edit_terms'   => 'manage_business_areas',
        'delete_terms' => 'manage_business_areas',
        'assign_terms' => 'edit_posts',
],

Categories being a default taxonomy, I had the manage_categories caps but since I haven't yet added the custom manage_business_areas cap to my user / role, the demonstrated scenario happens.

You could easily test it by manually removing the edit_categories capability using something like the Members plugin.

@mathieuhays
7 years ago

#4 @mathieuhays
7 years ago

  • Keywords has-patch added; needs-patch removed

I've implemented a patch adding a variable $has_2_columns_layout governing whether or not to add the col_left col_right markup.

#5 @marcwieland95
7 years ago

  • Keywords dev-feedback added

I've tested the scenario.

On the built-in category, there's no possibility this could happen because manage_terms, edit_terms and delete_terms maps to the same capability.
On a custom taxonomy, the scenario can happen when manage_terms is set on the user and edit_termsand delete_terms is not set.

The Patch fixes the layout. It also works responsively.

#6 @jameskockelbergh
7 years ago

The layout proposal of @swissspidy is a good solution as it improves UX.

#7 @swissspidy
7 years ago

  • Milestone changed from Awaiting Review to 5.1

#8 @swissspidy
7 years ago

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

Marking this good-first-bug ticket as claimed.

@swissspidy
6 years ago

#9 @swissspidy
6 years ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 44515:

Taxonomy: Display term list table in full width if there is no edit form.

Makes sure there is no empty space when a user can manage terms but lacks the capability to edit terms.

Props mathieuhays, marcwieland95.
Fixes #43743.

#10 @swissspidy
6 years ago

In 44516:

Build/Test Tools: Fix coding standards issues after [44515] and [44514].

See #44494, #43743.

Note: See TracTickets for help on using tickets.