Prerequisites
Proposal
Currently when
flattenEmptyDirectories: true is
enabled, each path segment is
individually wrapped in a Truncate
component, resulting in display
like:
a... / b... / c... / dd... / ...
We'd like to support an option to
truncate the whole flattened path
at the end, like:
aaa / bbb / ccc /...
This is more readable and matches
how most file explorers (e.g. VS
Code) handle deep nested paths.
Proposed API:
useFileTree({
flattenEmptyDirectories: true,
flattenedSegmentsTruncation:
'end', // 'per-segment' (default) |
'end'
})
Or alternatively a CSS variable /
data attribute that consumers can
use to override the truncation
strategy via unsafeCSS.
Motivation and context
When flattenEmptyDirectories: true
is enabled and the tree is rendered
in a narrow container (e.g. a
sidebar panel pushed to the right
edge), the per-segment truncation
produces a very poor visual result
— every segment gets clipped
individually, leaving a string of
disconnected ellipses like a... /
b... / c... / dd... / .... This
makes the path nearly unreadable
and wastes space with repeated ...
markers.
VS Code handles this well by
truncating the entire flattened
path as a single string at the end
(aaa / bbb / ccc /...), which keeps
as much of the path visible as
possible and is far easier to scan
at a glance. Supporting
end-truncation for the whole path
would bring @pierre/trees in line
with this established UX pattern
and significantly improve usability
in space-constrained layouts.
Prerequisites
Proposal
Currently when
flattenEmptyDirectories: true is
enabled, each path segment is
individually wrapped in a Truncate
component, resulting in display
like:
a... / b... / c... / dd... / ...
We'd like to support an option to
truncate the whole flattened path
at the end, like:
aaa / bbb / ccc /...
This is more readable and matches
how most file explorers (e.g. VS
Code) handle deep nested paths.
Proposed API:
Or alternatively a CSS variable /
data attribute that consumers can
use to override the truncation
strategy via unsafeCSS.
Motivation and context
When flattenEmptyDirectories: true
is enabled and the tree is rendered
in a narrow container (e.g. a
sidebar panel pushed to the right
edge), the per-segment truncation
produces a very poor visual result
— every segment gets clipped
individually, leaving a string of
disconnected ellipses like a... /
b... / c... / dd... / .... This
makes the path nearly unreadable
and wastes space with repeated ...
markers.
VS Code handles this well by
truncating the entire flattened
path as a single string at the end
(aaa / bbb / ccc /...), which keeps
as much of the path visible as
possible and is far easier to scan
at a glance. Supporting
end-truncation for the whole path
would bring @pierre/trees in line
with this established UX pattern
and significantly improve usability
in space-constrained layouts.