While updating modal usages in journal-web, I stumbled upon quite odd code related to More button in Management Toolbar Creation Menu.
Steps to reproduce:
- Control Panel > Site > Web Content > Structures tab
- Create 10 structures. Yes, 10. There probably is a config somewhere that can change this
- Web Content tab > create new web content on > More. Modal opens.
- Close modal on
What happens is page refreshes, for seemingly no reason. I am not sure if this was done deliberately as a workaround, or it just hid the root issue.
After I cleaned up the code, replacing modal with new `openModal` util, I got this behavior:
- While modal is being opened, there is a flash of dropdown menu with all items.
- After modal is closed, dropdown menu shows all items. There is no `More` button, until the page is refreshed. This is likely why we are refreshing page in the current code.
As Chema Balsas said here, we wanted this
There's 2 courses of action not necessarily exclusive:
- The proper functionality should be implemented in ddm so that the more button triggers the proper modal.
- The dropdown menu should have a default behaviour of showing all the elements when the modal functionality hasn't been implemented.
The problem is, both behaviors happen at once, if modal is implemented. `event.preventDefault();` was probably attempt to prevent list extending, but it doesn't work. The intended default behavior in `ManagementToolbar.es.js` executes first, or the order may be random.
Possible solution directions:
- Remove extend behavior and implement modal on Widget templates page
- Add a mechanism that executes extension only if modal is not implemented. This may be some event handle override mechanism, I don't know how that could be implemented. It could also be something like attribute on button, determining if we are in modal or legacy mode.
- We could keep the unfortunate page refresh workaround, and somehow find a way to prevent change flash while modal is opening.