Prerequisites
Describe the issue
FileTreeView renders every row name through MiddleTruncate with minimumLength: 5 and split: "extension":
|
<MiddleTruncate minimumLength={5} split="extension"> |
|
{row.name} |
|
</MiddleTruncate> |
For names without a dot, splitExtension falls back to Math.ceil(length / 2):
|
export const splitExtension: CustomSplitFn = (contents) => { |
|
if (contents.length < 4) { |
|
return [contents, '']; |
|
} |
|
const lastDotIndex = contents.lastIndexOf('.'); |
|
const extensionIndex = lastDotIndex + 1; |
|
const impliedExtensionLength = contents.length - extensionIndex; |
|
const maxExtensionLength = 10; |
|
const isTooLong = impliedExtensionLength > maxExtensionLength; |
|
|
|
const splitIndex = |
|
extensionIndex >= 1 && !isTooLong |
|
? extensionIndex |
|
: Math.ceil(contents.length / 2); |
|
|
|
return [contents.slice(0, splitIndex), contents.slice(splitIndex)]; |
|
}; |
When that fallback splitIndex lands right after a space, the first segment ends with a trailing space. The two segments are then rendered side by side as inline elements, with the visible content carrying white-space: nowrap:
|
[data-truncate-content='visible'] { |
|
white-space: nowrap; |
Standard inline layout collapses the trailing whitespace at that boundary, so the name visually loses its space. The space is still present in the DOM (visible via the inspector), it just not "visible".
Example: "Hello world" (11 chars) = split at 6 = ["Hello ", "world"] = renders as Helloworld.
So the trigger is: extensionless name, length >= 5, with a space such that Math.ceil(length / 2) falls right after it.
Pretty niche, but I spent a few moments debugging this convinced the issue was on my side, haha 😅 Also, happy to try a PR if you think this is a good first issue.
Reproduction
On https://trees.software/, create a folder or file named Hello world. The row renders as Helloworld.
What browser(s) are you seeing the problem on?
No response
What version of @pierre/trees are you using?
1.0.0-beta.4
Prerequisites
Describe the issue
FileTreeViewrenders every row name throughMiddleTruncatewithminimumLength: 5andsplit: "extension":pierre/packages/trees/src/render/FileTreeView.tsx
Lines 880 to 882 in a38cade
For names without a dot,
splitExtensionfalls back toMath.ceil(length / 2):pierre/packages/trees/src/components/OverflowText.tsx
Lines 70 to 86 in a38cade
When that fallback
splitIndexlands right after a space, the first segment ends with a trailing space. The two segments are then rendered side by side as inline elements, with the visible content carryingwhite-space: nowrap:pierre/packages/truncate/src/style.css
Lines 82 to 83 in a38cade
Standard inline layout collapses the trailing whitespace at that boundary, so the name visually loses its space. The space is still present in the DOM (visible via the inspector), it just not "visible".
Example:
"Hello world"(11 chars) = split at 6 =["Hello ", "world"]= renders asHelloworld.So the trigger is: extensionless name, length >= 5, with a space such that
Math.ceil(length / 2)falls right after it.Pretty niche, but I spent a few moments debugging this convinced the issue was on my side, haha 😅 Also, happy to try a PR if you think this is a good first issue.
Reproduction
On https://trees.software/, create a folder or file named
Hello world. The row renders asHelloworld.What browser(s) are you seeing the problem on?
No response
What version of @pierre/trees are you using?
1.0.0-beta.4