Skip to content

Feature: flattenEmptyDirectories: support end-truncation for the whole flattened path instead of per-segment truncation #1027

Description

@lucifer-yf

Prerequisites

Proposal

Currently when
flattenEmptyDirectories: true is
enabled, each path segment is
individually wrapped in a Truncate
component, resulting in display
like:

Image

a... / b... / c... / dd... / ...

We'd like to support an option to
truncate the whole flattened path
at the end, like:

Image

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

Image Image

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions