WordPress.org

Make WordPress Core

Opened 19 months ago

Last modified 3 weeks ago

#42937 reviewing enhancement

Success Message should display on insertion of new category in Taxonomy page

Reported by: manishamakhija Owned by: SergeyBiryukov
Milestone: 5.3 Priority: normal
Severity: normal Version: 4.9.1
Component: Taxonomy Keywords: has-patch has-screenshots has-unit-tests input-validation
Focuses: ui, accessibility, administration Cc:

Description

When we add new category then apart from displaying a new category at the top, there should also display a success message like 'new category added successfully' same as we have in 'Add new post' Page.
https://www.awesomescreenshot.com/image/3050291/30f92b69674d681274d708ec6d6e472b

https://www.awesomescreenshot.com/image/3050289/1e5164792645bf217b32b93d2f33e2bc

Attachments (9)

42937.patch (2.3 KB) - added by manishamakhija 19 months ago.
post-message.png (28.7 KB) - added by birgire 19 months ago.
Post Update Message (current)
category-message.png (44.4 KB) - added by birgire 19 months ago.
Category Update Message (suggested)
42937.1.patch (2.4 KB) - added by manishamakhija 19 months ago.
translatable message and category link added
42937.2.patch (2.2 KB) - added by dilipbheda 19 months ago.
Coding Standard Improvement
error-in-UI-in-add-term.webm (5.7 MB) - added by manishamakhija 16 months ago.
New term not append in term list after successful insertion
42937.3.diff (2.4 KB) - added by birgire 16 months ago.
category-added-ajax-message-with-42937.3.diff.jpg (36.7 KB) - added by birgire 16 months ago.
42937.4.diff (7.7 KB) - added by birgire 16 months ago.

Change History (24)

#1 @manishamakhija
19 months ago

  • Keywords has-patch needs-unit-tests added

I have added patch for this ticket

#2 @birgire
19 months ago

Hi @manishamakhija, welcome to WordPress trac.

This looks like a good improvement, I recall adding tags/categories and not being sure if it was added or not.

I noticed that the following string in 42937.patch is not translatable:

$message = 'New '. $tax->labels->singular_name . ' created successfully'; 

Suggestion:

$message = sprintf( __( 'New %s created successfully.' ), $tax->labels->singular_name ); 
Last edited 19 months ago by birgire (previous) (diff)

@birgire
19 months ago

Post Update Message (current)

@birgire
19 months ago

Category Update Message (suggested)

#3 @birgire
19 months ago

  • Focuses ui added
  • Keywords has-screenshots added

@manishamakhija I uploaded your screenshots here above, to avoid them being lost if the image hosting changes.

@manishamakhija
19 months ago

translatable message and category link added

#4 @manishamakhija
19 months ago

Thanks @birgire for your suggestions. I've modified the patch.

#5 @chetan200891
19 months ago

  • Focuses administration added

#6 @dilipbheda
19 months ago

I have made changes to existing .patch to improve coding standard.

  1. Whitespace found at end of line
  2. Expected 1 space before/after closing bracket.
  3. if/else/for/while/try blocks should always use braces

@dilipbheda
19 months ago

Coding Standard Improvement

@manishamakhija
16 months ago

New term not append in term list after successful insertion

#7 @manishamakhija
16 months ago

Need for this new enhancement:
In one of my project when I was entering new term in category, it doesn't show at the top/first position though it is added in the backend which displays after page refresh. For more clarification see video I've attached in it. So it's better if we can add success message too.

@birgire
16 months ago

#8 @birgire
16 months ago

I had another look at this and I would suggest we limit the scope of the ticket to the existing "added" messages. We can see the existing messages here:

https://core.trac.wordpress.org/browser/tags/4.9.5/src/wp-admin/includes/edit-tag-messages.php

There are only three variations for "added":

  • Category added.
  • Tag added.
  • Item added.

where the last one is for a taxonomy that's neither a category or a post_tag.

I also think we should have the "added" ajax admin notice dismissable.

Usually that's done via CSS classes like: notice is-dismissible.

But that's not triggered here via ajax. I think a workaround for that is to trigger the 'wp-updates-notice-added' event.

42937.3.diff is a suggested patch that:

  • Adds a message according to the three existing variations, mentioned above.
  • Adds CSS classes to the admin notice.
  • Makes the admin notice dismissable, by triggering the 'wp-updates-notice-added' event.

Todo:

  • Find a way to use the translated strings from the $messages array and make the ajax "added" message filterable by term_updated_messages.

Further:

  • If we want to modify the "added" message, then I think a new ticket would serve it better.
  • I wonder if the "deleted" message should be considered too? (If so then in another ticket).
Last edited 16 months ago by birgire (previous) (diff)

#9 @birgire
16 months ago

42937.4.diff is a suggested way to:

  • Reuse the translated strings from the $messages array (i.e. with index 3).
  • Allow the message to be filterable with term_updated_messages.
  • Add tests within the new Tests_Ajax_AddTag class with methods:
    • test_add_category().
    • test_add_post_tag().
    • test_add_category_should_work_with_message_filtering().
    • test_adding_category_without_capability_should_error().
    • test_adding_existing_category_should_error().


Last edited 16 months ago by birgire (previous) (diff)

@birgire
16 months ago

#10 @birgire
16 months ago

  • Keywords has-unit-tests added; needs-unit-tests removed

#11 @gounder
15 months ago

I find this issue with all taxonomies including tags, product categories in WooCommerce or Custom Taxonomies. This really gets difficult when you already have a lot of taxonomy and you have to search for where your addition was added.

other than the message stating which category was added I would suggest like when a category gets deleted that row is highlighted in red the newly added taxonomy is highlighter in green.

http://tsara.demo.inkmyweb.com/wp-content/uploads/2018/04/Screen-Shot-2018-04-22-at-10.40.41-PM.png

#12 @SergeyBiryukov
3 months ago

  • Milestone changed from Awaiting Review to 5.3
  • Owner set to SergeyBiryukov
  • Status changed from new to reviewing

#13 @afercia
6 weeks ago

  • Focuses accessibility added
  • Keywords input-validation added

#15 @afercia
3 weeks ago

Thanks everyone for this ticket, patch, and feedback. I'd like to propose a further improvement: when a new term gets created, there's no feedback at all for screen readers. A simple wp.a11y.speak() message would be great, using the same already existing strings for categories, tags, and custom taxonomies:

'Category added.' / 'Tag added.' / 'Term added.'

It would be great to add a speak() message also when terms are deleted :)

Note: See TracTickets for help on using tickets.