-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #4489: Adding last resort truncation to User Model's getShortName() function #4533
Conversation
Thanks for this @Bajszi97! Could you tweak this to use three dots instead of two? To form a full ellipsis. It would be good to add a test to cover the originally raised issue in #4489, just a check to view a page with a comment and ensure the expected truncated name is visible. |
Even better, use the actual ellipses character: |
Of course, I will change that. I have discarded the idea of reducing the truncated length, as it will cause problems on numbers smaller than three, even though it's very unlikely to call the function with such a small length. I will use the actual ellipses character, if it's considered better practice.
Yes i would. I have never done testing before, but feels like a good way to start. If i can't make it work, i will inform you here. |
I have applied the changes you mentioned and managed to come up with something for the test, but I have some concerns regarding it. |
- Updating formatting. - Tweaked truncation to roughly match elipsis char to width used. - Updated testing to use existing helpers, and ran check as admin user to avoid name conflicts.
Thanks @Bajszi97, now merged for next feature release. I also adjusted the truncation to two, just because with @otherjoel's suggestion, I roughly measured the visual width of that character to be just over baseline character width, so I rounded up to consider it as 2 characters. |
This pull request closes issue #4489
by providing a last resort option to the getShortName() function within the User model. This option is necessary because the function fails to return anything in some cases. If the name is too long and cannot be split by spaces, it will be trimmed to the specified number of characters, followed by two dots ('..').