joomla / joomla-cms

Home of the Joomla! Content Management System
https://www.joomla.org
GNU General Public License v2.0
4.77k stars 3.65k forks source link

[4.0] The side menu for any component collapse when reloading the page #30155

Closed JackJoeJack closed 4 years ago

JackJoeJack commented 4 years ago

Steps to reproduce the issue

At the back-office, on any page that shows the side menu, and it is not toggled/reduced. At the side menu, click the "Content" item, it reveals its sub-items. Click the "Articles" item.

screen shot 2020-07-21 at 09 23 54

Expected result

When the "Articles" page loads, it should keep the "Content" side menu open (showing the "Articles", "Categories", etc).

screen shot 2020-07-21 at 09 24 14

Actual result

When the "Articles" page loads, the side menu has collapsed to its default (closed) state (the "Content" side menu only has siblings shown, not the chidren, and most importantly, the active menu is hidden).

screen shot 2020-07-21 at 09 24 46

System information (as much as possible)

MacOS 10.14.6; screen size: 1920 x 1080; using MAMP 5.2 (PHP 7.2); Joomla Beta 3 nightly build (Tuesday, 21 July 2020 02:00:26 UTC); tested in the following browsers: Google Chrome Version 84.0.4147.89 for Mac (the latest), Safari Version 12.1.2 (14607.3.9) Mac, Firefox 78.0.2 (64-bit) Mac, Microsoft Edge Version 79.0.309.65 Mac.

Additional comments

The same wrong behaviour happens with any other component. This was tested in a desktop only. Standard install of Joomla, and no changes made.

toivo commented 4 years ago

Just posted the following to the Forum topic The side menu for the components is always hidden?

"Just connected from MacBook Pro to the latest NB hosted in Wampserver in the LAN. Both Chrome 84 and Safari 13.1.1 opened the New Article window and used the whole width of the screen but as soon as the article was closed, the open sub menu was displayed, showing the active item.

Is it possible that the issue occurs only in the MAMP environment?"


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

JackJoeJack commented 4 years ago

You're right! I just tried on an external server, and it works! Who would imagine this would be related to the server? Even so, could it be any PHP module missing? I'm trying to find out...


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

JackJoeJack commented 4 years ago

Ok, I found out what is the problem!

The path name cannot contain any uppercase letters!

Just to explain better, I have installed Joomla 4 into a localhost domain that I have named "sandbox.dev" (this is in MAMP, and with a custom domain that I control with my hosts file), and extracted the zip into the root of this domain, so that to access it, I just have to type: https://sandbox.dev/Joomla_4.0.0-beta3-dev-Development-Full_Package/administrator/

If I tried to browse the admin, it would have the bug that I reported.

After some digging, I discovered that the domain folder cannot have uppercase characters, and so if I try: https://sandbox.dev/joomla_4.0.0-beta3-dev-development-full_package/administrator/

It works correctly and the side menu shows the active sub-menus when loading the pages!


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

PhocaCz commented 4 years ago

Hi,

confirmed. I am testing it on localhost.

When:

a) localhost/J4/administrator ... this bug occurs

when:

b) localhost/j4/administrator ... everything is OK.

(J4 => j4) ... problem is uppercase in path

Jan

infograf768 commented 4 years ago

Shall we close this?

JackJoeJack commented 4 years ago

Shall we close this?

This bug is still a bug, maybe report that the uppercase path can cause this?

infograf768 commented 4 years ago

Well, for me, it is NOT a joomla bug... This may happen on any site with any CMS. It is known that using Uppercase in links following the domain name may create issues, including 404.

infograf768 commented 4 years ago

Maybe we can correct that in the js. Not sure.

PhocaCz commented 4 years ago

This is very interesting issue. I have been testing on localhost for over 15 years. On Linux and Windows. On windows, I use capital letters in projects and I've never had such a problem.

If I had problems with 404, then it would be logical to focus on that. The insidiousness of this problem, however, is that it is not actually related to the URL directly - no 404, no error, no "server not found", etc.

Basically no one expects that marking an active menu item doesn't work due to an URL when the URL itself works correctly. Really hard to say.

infograf768 commented 4 years ago

Some one has to dig into the js to try to solve this.

JackJoeJack commented 4 years ago

This is very interesting issue. I have been testing on localhost for over 15 years. On Linux and Windows. On windows, I use capital letters in projects and I've never had such a problem.

If I had problems with 404, then it would be logical to focus on that. The insidiousness of this problem, however, is that it is not actually related to the URL directly - no 404, no error, no "server not found", etc.

Basically no one expects that marking an active menu item doesn't work due to an URL when the URL itself works correctly. Really hard to say.

True, I found out about it after a lot of digging, and testing PHP modules on/off. It was a lucky guess that made me check the path naming (periods, dashes, underscore, etc). Indeed there is no javascript error, and that made it even more difficult to spot.

infograf768 commented 4 years ago

Maintainers (@HLeithner @richard67 ) found the solution in the admin-menu.js Patch coming soon.

PhocaCz commented 4 years ago

I am not a Javascript expert, so therefore, I would rather not create PR but if I change following file:

_media/modmenu/js/admin-menu.es6.js (minified: _media/modmenu/js/admin-menu.min.js)

on line cca. 124

FROM: if (currentUrl === link.href) {

TO:

if (currentUrl.toLowerCase() === link.href.toLowerCase()) {

everythings is working OK.

(currentUrl includes real URL, link.href includes URL in lowercase format)

EDIT: I didn't see the previous comment from @infograf768 about solution by maintainers. Now I see it, great to heart it.

Thank you.

infograf768 commented 4 years ago

In fact, we choose to take off toLowercase() from currentUrl. will do patch tomorrow

Fedik commented 4 years ago

hm, try to change here https://github.com/joomla/joomla-cms/blob/8802276d77493895ba93c0dd24c6f5cd3aa9d697/build/media_source/mod_menu/js/admin-menu.es6.js#L78-L80

from:

menuToggle.addEventListener('click', () => {

to:

menuToggle.addEventListener('click', (event) => {
  event.preventDefault();
infograf768 commented 4 years ago

@Fedik Your proposal does not work here. PR here https://github.com/joomla/joomla-cms/pull/30170