Skip to content

feat(Truncate): Add true calculated middle truncate #11638

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

Closed
wants to merge 1 commit into from

Conversation

mfrances17
Copy link
Contributor

What: Closes #10892

This will add a true middle truncate if middle truncate is chosen and a value of 0 is passed for the trailing chars.

@mfrances17 mfrances17 requested a review from a team March 8, 2025 17:04
@mfrances17 mfrances17 self-assigned this Mar 8, 2025
@mfrances17 mfrances17 requested review from wise-king-sullyman and kmcfaul and removed request for a team March 8, 2025 17:04
@patternfly-build
Copy link
Contributor

patternfly-build commented Mar 8, 2025

Copy link
Contributor

@thatblindgeye thatblindgeye left a comment

Choose a reason for hiding this comment

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

Might be noticing some odd behavior.

  • When I pass a string of 40 characters (xXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxXxX), I was expecting to have the same amount of characters in either side of the ellipsis, but I end up with 18 before the ellipsis and 20 after.
  • Before the truncation occurs, there's a large white space that slowly shrinks as more characters are added. Screenshot when only 4 characters are present:
    image
  • Not sure if there's a better solution, but not 100% on having trailingNumChars of 0 acting as the trigger to apply the true middle truncation. Possibly updating the type of the prop to number or "auto", but the auto would really only take affect for middle truncation. A new position value of "auto-middle" maybe. This isn't really a blocker for me, but might be good to discuss before we're locked into the logic.

@kmcfaul
Copy link
Contributor

kmcfaul commented Mar 11, 2025

I'm a little confused how this is supposed to behave overall. In the updated example, if you change the string to longer text, or resize the text area, the ellipsis in the middle will still shift to the left. It calculates the middle of the content but otherwise behaves the same as trailing number of characters. Is this the intended pattern opposed to trying to keep the ellipsis centered?

@mfrances17 mfrances17 removed their assignment Mar 12, 2025
@thatblindgeye
Copy link
Contributor

Closing for now as we merged #11742 as another implementation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Truncate - True calculated middle truncate
4 participants