Skip to content

Conversation

pedroasgomes
Copy link
Contributor

@pedroasgomes pedroasgomes commented Apr 1, 2025

Q A
Bug fix? (use the a.b branch) ✔️
New feature/enhancement? (use the a.x branch)
Deprecations?
BC breaks? (use the c.x branch)
Automated tests included? ✔️
Related user documentation PR URL N/A
Related developer documentation PR URL N/A
Issue(s) addressed Fixes #14240

Description

This PR fixes an issue where the dropdown menu for individual non-system themes showed a blank link in the list of available actions. The issue was caused by empty button definitions being passed to the customButtons array in the Twig template.

To fix this, the list.html.twig file was updated to ensure that only properly defined buttons are merged into the customButtons array. Buttons such as the preview or visibility toggles are now conditionally added only when they are not empty, preventing malformed entries from being rendered.

An E2E test is included to ensure that no action link with data-toggle="ajax" is rendered without a corresponding href attribute.

Before After
Before After

📋 Steps to test this PR:

  1. Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
  2. Navigate to the Themes Page
  3. Locate a theme that is not set as system theme (that can be removed).
  4. Click the dropdown for actions.
  5. Confirm the result

@escopecz
Copy link
Member

escopecz commented Apr 4, 2025

Hey! Thanks for this fix! It's amazing!

  1. I think we should find why is there the empty option rather than ignoring empty options. I think the empty option happens here: https://github.com/mautic/mautic/blob/7.x/app/bundles/CoreBundle/Resources/views/Theme/list.html.twig#L33. It shouldn't be added to the customButtons array if it's empty.
  2. The test checks if there is a link with data-toggle="ajax" attribute. How about to check rather if the link has a href attribute and if it doesn't then fail the test? That could be more helpful.

@escopecz escopecz added bug Issues or PR's relating to bugs user-interface Anything related to appearance, layout, and interactivity pending-feedback PR's and issues that are awaiting feedback from the author themes Anything related to themes labels Apr 4, 2025
When clicking to open the list dropdown for a theme on the Themes page,
blank links are shown at the top and it happens only for themes that are
not set as system theme.
To fix this, Resources/views/Theme/list.html.twig was updated to prevent
empty button definitions from being added to the `customButtons` array.
Now, only buttons with proper attributes are merged into the list of
actions shown in the dropdown menu.
An E2E test is included to verify that no links with
`data-toggle="ajax"` are rendered without a `href` attribute.
@pedroasgomes
Copy link
Contributor Author

Hi @escopecz, just following up — the changes were pushed over the weekend:

  • Empty buttons are now filtered before being added to customButtons in the Twig template
  • An E2E test ensures that no data-toggle="ajax" link is rendered without a href

Let me know if this aligns with what you had in mind, and I’m happy to adjust if needed. Appreciate your time!

@escopecz escopecz self-requested a review April 7, 2025 08:36
escopecz
escopecz previously approved these changes Apr 7, 2025
Copy link
Member

@escopecz escopecz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code changes look great! And I tested it and it fixes the empty menu item.
Screenshot 2025-04-07 at 10 41 18

Thank you!

@escopecz escopecz added code-review-passed PRs which have passed code review user-testing-passed PRs which have been successfully tested by the required number of people. and removed pending-feedback PR's and issues that are awaiting feedback from the author labels Apr 7, 2025
@escopecz escopecz added this to the 6.0.1 milestone Apr 7, 2025
@escopecz
Copy link
Member

escopecz commented Apr 7, 2025

One last thing is that the CS Fixer is failing. Please run

bin/php-cs-fixer fix --config=.php-cs-fixer.php --using-cache=no --show-progress=dots --diff tests/_support/Page/Acceptance/ThemesPage.php tests/acceptance/ThemeManagementCest.php

To fix these issues.

@escopecz escopecz added the pending-feedback PR's and issues that are awaiting feedback from the author label Apr 7, 2025
Copy link

codecov bot commented Apr 7, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.74%. Comparing base (12f062e) to head (d3d530e).
Report is 7 commits behind head on 6.0.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                6.0   #14833      +/-   ##
============================================
- Coverage     64.75%   64.74%   -0.01%     
  Complexity    34728    34728              
============================================
  Files          2275     2275              
  Lines        103739   103739              
============================================
- Hits          67171    67170       -1     
- Misses        36568    36569       +1     

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Fixes PHP CS violations flagged during review. No
logic or structure changes were made — only style
adjustments in accordance with the
`.php-cs-fixer.php` config.
Copy link
Member

@escopecz escopecz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! The changes looks good, and works as described 👍

@escopecz escopecz merged commit f014d59 into mautic:6.0 Apr 7, 2025
27 checks passed
@escopecz escopecz removed the pending-feedback PR's and issues that are awaiting feedback from the author label Apr 7, 2025
@escopecz
Copy link
Member

escopecz commented Apr 7, 2025

@all-contributors please add @pedroasgomes for code

Copy link
Contributor

@escopecz

I've put up a pull request to add @pedroasgomes! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues or PR's relating to bugs code-review-passed PRs which have passed code review themes Anything related to themes user-interface Anything related to appearance, layout, and interactivity user-testing-passed PRs which have been successfully tested by the required number of people.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants