Make WordPress Core

Opened 8 years ago

Closed 5 years ago

#38415 closed defect (bug) (fixed)

New Custom Link menu item has a wrong fallback label

Reported by: afercia's profile afercia Owned by: afercia's profile afercia
Milestone: 5.2.3 Priority: normal
Severity: normal Version: 4.5
Component: Menus Keywords: has-screenshots good-first-bug has-patch needs-testing fixed-major
Focuses: ui Cc:

Description (last modified by desrosj)

On the menus screen, when adding a Custom Link to a menu and leaving the link text field empty, a default fallback Menu Item label was set:

https://cldup.com/xaDohbjzS9.png

On the latest versions though, the fallback label is (Pending), with a leading space:

https://cldup.com/zq1ti4qSnq.png

This was broken by [36379] my bad. Haven't looked in depth in the code but I think it could be fixed on the PHP side, I guess there's no need to restore the JS part that was removed in [36379].

Attachments (4)

38415.patch (692 bytes) - added by thakkarhardik 6 years ago.
As per the suggestion, I have changed the label. Please look over it and let me know if anything more is required.
38415.diff (608 bytes) - added by afercia 5 years ago.
menu-item-label-before.png (43.4 KB) - added by audrasjb 5 years ago.
Before 38415.diff
menu-item-label-after.png (56.8 KB) - added by audrasjb 5 years ago.
After 38415.diff - Works fine!

Download all attachments as: .zip

Change History (21)

#1 follow-up: @christophherr
8 years ago

Would a feasible approach be to simply add Menu Item to
https://core.trac.wordpress.org/browser/trunk/src/wp-admin/includes/class-walker-nav-menu-edit.php#L103?
e.g.:

$title = sprintf( __('%s Menu Item (Pending)'), $item->title );

https://cldup.com/exbrWmnc2t.png

Last edited 8 years ago by christophherr (previous) (diff)

#2 in reply to: ↑ 1 @Fencer04
8 years ago

I think having Menu Item (Pending) makes sense. I'm new to this but is there a reason we don't make the text field for Custom Links required?

#3 @desrosj
6 years ago

  • Description modified (diff)
  • Keywords needs-patch good-first-bug added
  • Milestone changed from Awaiting Review to Future Release

@thakkarhardik
6 years ago

As per the suggestion, I have changed the label. Please look over it and let me know if anything more is required.

#4 @thakkarhardik
6 years ago

  • Keywords has-patch added; needs-patch removed

#5 @backermann1978
5 years ago

Works fine with my local VVV-setup and fixes the issue (tested on WordCamp EU Contributor Day).

#6 @antpb
5 years ago

  • Keywords commit added

#7 @afercia
5 years ago

  • Milestone changed from Future Release to 5.3
  • Owner set to afercia
  • Status changed from new to assigned

#8 @afercia
5 years ago

  • Keywords commit removed

Thanks everyone! I tried to look a bit more in depth into this and there are a few things to consider. Testing with JavaScript support disabled and enabled:

JavaScript disabled:
When adding menu items, an additional string (Pending) gets appended to the item name. Also, a notice "Click Save Menu..." appears at the top:

http://cldup.com/dXLp0ChW_X.png

Looks like this part was never implemented in the JavaScript-based implementation.

JavaScript enabled:
The additional string (Pending) is intentionally not displayed. Also the notice doesn't appear.

To respect the original implementation, the string (Pending) shouldn't be displayed. I'd like to propose to just restore the original behavior: when a custom link text is empty, a default "Menu Item" string is used as fallback.

I've noticed a couple inconsistencies in the PHP part and I'm not sure the Custom Links are fully functional when JavaScript is disabled but seems to me those are pre-existing issues. Considering the Menu page will be refactored soon to use blocks, I'd tend to think the best option is to restore a mechanism to have the fallback to athe"Menu Item" string.

@afercia
5 years ago

#9 @afercia
5 years ago

38415.diff adds a fallback to Menu Item in the ajax action used for the JS implementation. This should restore the original behavior as detailed above. Some testing would be nice :)

Last edited 5 years ago by afercia (previous) (diff)

@audrasjb
5 years ago

Before 38415.diff

@audrasjb
5 years ago

After 38415.diff - Works fine!

#10 @audrasjb
5 years ago

@afercia I tested the patch and it looks good on my side (see screenshots above).

#11 @afercia
5 years ago

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

In 45727:

Menus: Fix the Custom Links text fallback.

When adding a Custom Link and leaving the "Link Text" field empty, WordPress used to set a default fallback text: "Menu Item".

The changes in [36379] broke this behavior making the fallback text: (Pending), with a leading space.

Pending major refactoring of the Menus page (which is going to use a block-based user interface) this change just restores the original behavior by adding the fallback text to the related AJAX response.

Props christophherr, Fencer04, thakkarhardik, backermann1978, audrasjb.
Fixes #38415.

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


5 years ago

#13 @audrasjb
5 years ago

  • Keywords needs-testing fixed-major added
  • Milestone changed from 5.3 to 5.2.3
  • Resolution fixed deleted
  • Status changed from closed to reopened

Reopening this so it can be back-ported to the 5.2 branch.
Adding needs-testing since we have to check it's ok to land in 5.2.3.

#14 @audrasjb
5 years ago

Tested on my side against 5.2.2. The patch looks good to go and works fine but unless I'm mistaken [45727] doesn't look to apply cleanly: ajax-actions.php seems to have some dependancies to previous commits.

#15 @JeffPaul
5 years ago

@afercia any insight into which commit(s) this may depend upon? If not, then we may be best moving this ticket back to 5.3 to limit risk in 5.2.3.

#16 @SergeyBiryukov
5 years ago

[45727] cleanly applied to the 5.2 branch for me.

#17 @SergeyBiryukov
5 years ago

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

In 45828:

Menus: Fix the Custom Links text fallback.

When adding a Custom Link and leaving the "Link Text" field empty, WordPress used to set a default fallback text: "Menu Item".

The changes in [36379] broke this behavior making the fallback text: (Pending), with a leading space.

Pending major refactoring of the Menus page (which is going to use a block-based user interface) this change just restores the original behavior by adding the fallback text to the related AJAX response.

Props christophherr, Fencer04, thakkarhardik, backermann1978, audrasjb.
Merges [45727] to the 5.2 branch.
Fixes #38415.

Note: See TracTickets for help on using tickets.