Skip to content

Conversation

@henrikdalgaard
Copy link
Contributor

@henrikdalgaard henrikdalgaard commented Dec 13, 2025

Pull Request for Issue #46566

Summary of Changes

The regex search and replace for menu items finds too many matches as the regex is not limited to one li tag. This results in extra edit links getting added. See screen shots.
An extra space is added to after the inserted edit link as it looks bad if flush against the menu item.
Tabs replaced with spaces in the same line.

Testing Instructions

Enable frontend editing on a page with a menu with lots of items.

Example buggy html output with fixed html
mod-menu1-buggy.html
mod-menu1-fixed.html

Actual result BEFORE applying this Pull Request

Notice the extra edit buttons to the left of two of the menu items.
buggy-menu

Expected result AFTER applying this Pull Request

fixed-menu

Link to documentations

Please select:

  • Documentation link for docs.joomla.org:

  • No documentation changes for docs.joomla.org needed

  • Pull Request link for manual.joomla.org:

  • No documentation changes for manual.joomla.org needed

@tecpromotion tecpromotion changed the title Tightened regex searching for menu items to prevent duplicate edit link icons #46567 [5.4] Tightened regex searching for menu items to prevent duplicate edit link icons #46567 Dec 13, 2025
@tecpromotion tecpromotion linked an issue Dec 13, 2025 that may be closed by this pull request
@richard67 richard67 added the bug label Dec 13, 2025
@exlemor
Copy link

exlemor commented Dec 13, 2025

@henrikdalgaard - sadly, I have not been able to reproduce the BEFORE condition - I set a side menu Main Menu - GB with 15+ items some with sub-menu and another Test Menu with itself 15 items and neither show double Pencil Checkbox ;(

(I had to go into Global Configuration and update the Frontend Editing field/option to Modules & Menu (you may wish to add that to the Testing Instructions))

( I wonder what other/additional condition is causing/creating the double icon ?

@brianteeman
Copy link
Contributor

I cant replicate the reported problem so cant validate the proposed fix

image

@henrikdalgaard
Copy link
Contributor Author

I have debugged it further.

To provoke the bug, I have menu items 31, 32, 33, 34, 35 and then 3 in the same menu.
3 is a prefix to some of the other item numbers.
The items not containing 3 are not affected.

The regex '/(<li.?\bitem-' . $menuItemid . '.?>)/' becomes '/(<li.?\bitem-3.?>)/' which will match

  • - basically all menu items beginning with 3.

    Screenshot showing my texteditor matching item 34 with the regex for item 3
    Matching menu item 34

    With the fixed regex, only menu item 3 is matched when searching for menu item 3.

    Here is the $moduleHtml before the links are added.

    Menu-without-editing-links.html

    and $moduleHtml after the links are added
    Menu-after-editing-links-added.html

    I notice that before adding the links, the entire menu is in a 3000 character wide line.

  • @exlemor
    Copy link

    exlemor commented Dec 21, 2025

    I have tested this item ✅ successfully on 4c5993d

    Hello @henrikdalgaard, thank you for your contribution and I have been able to successfully match the BEFORE and AFTER conditions now. It is now fixed.

    (For other testers, I did have to edit the database to recreate the situation needed (my IDs were in the 130's and I had to update an entry that wasn't a duplicate to 13 to make the condition appear)

    To make sure that this worked with more complex menu/sub-menu structures, I also created deeper structures than your example:

    Home
     - Test link for PR46569
     - Test Link 2 for PR46569
     - Test link 3 for PR46569
     - Test Link (13) for PR46569
    

    and 3 levels deep

     Home
     - Test link for PR46569
     -- Test of Sub-subcategories for PR46569
     --- Test Link 2 for PR46569
     --- Test link 3 for PR46569
     --- Test Link (13) for PR46569
    

    Happy Holidays!


    This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46569.

    @richard67
    Copy link
    Member

    @henrikdalgaard There is no need to update the PR to changes in the base branch as long as there are no conflicts shown on GitHub. Now with your branch update you have invalidated the human test count, so I have to manually add back @exlemor 's successful test. This causes additional work for me.

    @ThomasFinnern
    Copy link
    Contributor

    I have tested this item ✅ successfully on 5103a73

    Needed: switch on Global Configuration (System > Global Config > Site > Frontend Editing: Set to "Modules & Menus"

    Created nested menu items. Problem seen before applying the PR.
    After applying the PR by patch tester the double "edit" icons were gone.
    Tested edit icons of not nested menu link and two nested links were working
    Tested deeper nested items successfully


    This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46569.

    @richard67
    Copy link
    Member

    RTC


    This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/46569.

    @joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Jan 2, 2026
    @richard67 richard67 added this to the Joomla! 5.4.3 milestone Jan 2, 2026
    @muhme
    Copy link
    Contributor

    muhme commented Jan 8, 2026

    ✅ Final test before merge with JBT

    • Seen missing space and double/trippled edit buttons before PR
      • Note, it was importand for me to understand the problem is the item ID, as my menu item IDs are 100 and above, the problem is easy to force by one of the entries with menu item title item-1 to see two edit buttons. And another one with item-11 to see three edit buttons 😄
    • Applied PR with gh pr checkout 46569
      • Seen doubled/tripled edit buttons are fixed
      • Space is inserted between edit button and title
      • Menu item edit links are working and menu links are working

    @muhme muhme merged commit e794ca4 into joomla:5.4-dev Jan 8, 2026
    69 checks passed
    @joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Jan 8, 2026
    @muhme
    Copy link
    Contributor

    muhme commented Jan 8, 2026

    Thank you @henrikdalgaard for your contribution. Thank you @brianteeman, @exlemor and @ThomasFinnern for testing.

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    Frontend editing creates duplicated edit icons on some menus

    7 participants