RetroAchievements / RAWeb

The RetroAchievements.org platform. Includes core functionality for managing achievements, game data, and community features.
https://retroachievements.org
GNU General Public License v3.0
254 stars 87 forks source link

Text Handling exceptions #2: User Motto not being exhibited correctly on certain situations on User Page and on User Card #1624

Closed Alexdatadestroyer closed 8 months ago

Alexdatadestroyer commented 1 year ago

Taking opportunity of my previous issue (#1619) which already has a solution provided (#1620). It's time to provide another information regarding Text Handling Exception once again. However, this only affects User Motto and its exhibition feature now: User Card and User Page.

Since this may also affect how Latin Characters (and Emojis) are handled on RA Website, I will report this before the next version release on RA Web comes to reality to avoid rework.

Try it for yourself! It's fun!

Switch (String.length)

1. Screenshots: Case 1:

a.1) Creating a User Motto sentence with only 1 character

b.1) User Page with NO User Motto exhibition...

c.1) User Motto is also absent on User Card

2. Screenshots: Case 2:

a.2) Creating a User Motto sentence with 2 characters

b.2) User Motto exhibited correctly on User Page...

c.2) However, User Card is messed again! (Don't be fooled, this isn't the same picture used on Case 1 even with it taken on another angle!)

3. Screenshots: Case 3 (default) - Accepted IF Characters >= 3:

a.3) Creating a User Motto sentence with 3 characters

b.3) User Motto exhibited correctly once again...

c.3) User Card now shows correctly User Motto sentence. Viva!

4. Other cases tested: Latin Characters & Emojis

For sake of reading, I won't post more images showing how UP and UC behaviored when UM was changed: Just a quick result of those cases:

a.4) Latin Characters:

1 char: UP (Yes) | UC (No) 2 chars: UP (Yes) | UC (No) 3 chars: UP (Yes) | UC (Yes) 4 chars: UP (Yes) | UC (Yes)

b.4) Emojis:

1 char: UP (No) | UC (No) 2 chars: UP (Yes) | UC (No) 3 chars: UP (Yes) | UC (Yes) 5 chars: UP (Yes) | UC (Yes)

Emojis behaviored the same way as Normal Character, but for Latin Characters, results differ. Both behaviored the same way for 2 characters or more.

5. Further Investigation:

Extra screenshot: LC alone being shown on User Page as valid User Motto sentence:

This report was long to write: It was hard to match things and write everything down, but I think that the issue is mapped correctly!

Exception Level: High -- Easy to Reproduce, Hard to notice. However, it's already affected other users for such a long time...

wescopeland commented 1 year ago

It is intentional for user mottos to not render in tooltips if they are only a single character.

https://github.com/RetroAchievements/RAWeb/blob/a200152e541e65b2d187722a8c7ca989ddb44e9b/app/Helpers/render/user.php#L109

Alexdatadestroyer commented 1 year ago

It is intentional for user mottos to not render in tooltips if they are only a single character.

https://github.com/RetroAchievements/RAWeb/blob/a200152e541e65b2d187722a8c7ca989ddb44e9b/app/Helpers/render/user.php#L109

Sure, I noticed that before. However, this is still buggy as it is giving unexpected behavior on such situations like explained above...

MSGoodman commented 9 months ago

Taking a look at this, I can see the situation is thus:

User Profile Page As seen in the code below (from userInfo.php), we never show a user motto unless it's more than 1 character:

if (isset($userMotto) && mb_strlen($userMotto) > 1) {
    echo "<div class='mottocontainer'>";
    echo "<span class='usermotto'>$userMotto</span>";
    echo "</div>";
}

User Card As seen in the code below (from user-card.blade.php), we never show a user motto unless it's more than 2 characters:

@if($motto !== null && mb_strlen($motto) > 2)
    <div class="mb-1 rounded bg-bg text-text italic p-1 text-2xs hyphens-auto">
        <p style="word-break: break-word;">{{ $motto }}</p>
    </div>
@endif

I am unsure what exactly we're referring to with "latin characters", but I'm going to guess it has something to do with encoding which is often a pain in the butt.

Anyhow, I have a few suggestions, any of which I'm happy to do:

  1. Make the display limitation here consistent between the two
  2. Remove the display limitation entirely and just show mottos regardless of length (doesn't seem like it'd hurt anything?)
  3. Consider it not a big deal and close the ticket

I'm more inclined towards 2 personally, but am happy to take someone else's lead here.

wescopeland commented 9 months ago

I also agree that choice 2 (remove conditionals on rendering if meeting a certain length) seems particularly desirable.

If someone wants their motto to be "A", more power to them. Concealing it from view seems like a dishonest design since we allow them to input the value in the first place.

When these cards were converted to Blade components, I retained this behavior, but truthfully I didn't understand why it was there in the first place.