menu.html.twig: avoid rendering empty style attribute in menu badges …#7510
Merged
javiereguiluz merged 1 commit intoEasyCorp:4.xfrom Mar 30, 2026
Merged
menu.html.twig: avoid rendering empty style attribute in menu badges …#7510javiereguiluz merged 1 commit intoEasyCorp:4.xfrom
javiereguiluz merged 1 commit intoEasyCorp:4.xfrom
Conversation
Seb33300
reviewed
Mar 19, 2026
| </span> | ||
| {% if item.badge %} | ||
| <span class="menu-item-badge rounded-pill badge {{ item.badge.cssClass }}" {{ _self.render_html_attributes(item.badge) }} style="{{ item.badge.htmlStyle }}">{{ item.badge.content }}</span> | ||
| <span class="menu-item-badge rounded-pill badge {{ item.badge.cssClass }}" {{ _self.render_html_attributes(item.badge) }} {{ item.badge.htmlStyle ? 'style="' ~ item.badge.htmlStyle ~ '"' : '' }}">{{ item.badge.content }}</span> |
Contributor
There was a problem hiding this comment.
cant we just rename htmlStyle to style, so this attribute will be rendered by render_html_attributes()?
Collaborator
There was a problem hiding this comment.
I'd prefer to keep the more explicit htmlStyle name for the HTML style attribute becaus ewe use style for the variant of the badge (primary, success, danger, etc.)
Contributor
There was a problem hiding this comment.
Or inside the render_html_attributes function, it may be handled automatically if htmlStyle is found
Collaborator
|
Thanks for fixing this bug @bt-nn. |
Contributor
Author
|
Thanks for merging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…(CSP compatibility)
EasyAdmin always rendered a
styleattribute for menu item badges, even whenitem.badge.htmlStylewas empty. This producedstyle="", which still counts as inline CSS and violates strict Content Security Policies (CSP) that do not allowunsafe-inline.The style attribute is now only rendered when a non-empty value is provided.