Repository navigation
fix: ranks join the user card's badges instead of breaking its layout - #181
Open
ernestdefoe wants to merge 1 commit into
Open
ernestdefoe wants to merge 1 commit into
ernestdefoe wants to merge 1 commit into
Conversation
In Flarum 2 the user card builds its badges in contentItems, inside UserCard-content. Gamification looked for them among UserCard-profile's children, never found them, and inserted a second badges list there, as an extra column between the avatar and the content. Fixes #170 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes #170.
Problem
In Flarum 2,
UserCardbuilds its badges incontentItems(), asUserCard-badgesinsideUserCard-content. The rank code still rewrote the rendered vnode the 1.x way. It searchedUserCard-profile's direct children for the badges list, never found it, and spliced a second<ul class="UserCard-badges">in at index 1, between the avatar and the content. That extra flex item pushes the rank into its own column and squeezes the user info into a narrow strip under the avatar, which is the issue's second screenshot. Users with group badges got the same column, with their group badge and rank in two separate lists.Before, the DOM on stock 2.0.2 for a user with a rank:
Fix
The ranks are added in
extend(UserCard.prototype, 'contentItems'). If the user already has abadgesitem, the rank<li>s join that list. They're keyed (rank-{id}) to match the keyed items fromlistItems. Otherwise abadgesitem is added at core's own priority, 90. The order (newest first) and thefof-gamification.rankAmtlimit are unchanged. The vnode-walking helper the old code needed is removed.PostUseris not touched.Tested
On stock Flarum 2.0.2 with the default theme:
UserCard-profile: [avatar, content], with badges[item-group1, User-Rank]. The rank sits next to the group badge on the name line.rankAmt = 2: one badges list holding the two newest ranks, in the same order as before.m.redraw.sync()doesn't duplicate ranks (2 → 2).check-typings,format-checkand the existing jest suite pass.js/distis left for the build bot.I didn't add a jest test for this. The repo's
@flarum/jest-configis 2.0.0, which has noflarum/*module mapping and whose forum bootstrap assumes it runs inside core, so renderingUserCardwould mean upgrading the test tooling in a layout fix. I'm happy to do that separately if you'd like.🤖 Generated with Claude Code